staging: rtl8188eu: Fix a sleep-in-atomic-context bug in issue_deauth_ex()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Sat, 15 Sep 2018 02:57:11 +0000 (10:57 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 18 Sep 2018 11:25:01 +0000 (13:25 +0200)
The driver may sleep with holding a spinlock.
The function call path (from bottom to top) in Linux-4.17 is:

[FUNC] msleep
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c, 1536:
msleep in issue_deauth_ex
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c, 5110:
issue_deauth_ex in disconnect_hdl
drivers/staging/rtl8188eu/core/rtw_cmd.c, 521:
disconnect_hdl in rtw_disassoc_cmd
drivers/staging/rtl8188eu/core/rtw_ioctl_set.c, 352:
rtw_disassoc_cmd in rtw_set_802_11_infrastructure_mode
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c, 1002:
rtw_set_802_11_infrastructure_mode in rtw_wx_set_wap
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c, 988:
spin_lock_bh in rtw_wx_set_wap

To fix this bug, msleep() is replaced with mdelay().

This bug is found by my static analysis tool DSAC.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c

index 213c8d6705917e870a04d0a6dee133e8fbcf8270..834053a0ae9d8fab01eebdbb7e1177389d2285da 100644 (file)
@@ -1513,7 +1513,7 @@ static int issue_deauth_ex(struct adapter *padapter, u8 *da,
                        break;
 
                if (i < try_cnt && wait_ms > 0 && ret == _FAIL)
-                       msleep(wait_ms);
+                       mdelay(wait_ms);
        } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0)));
 
        if (ret != _FAIL) {