staging: rtl8188eu: Fix two sleep-in-atomic-context bugs in rtw_chk_hi_queue_cmd()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Sat, 1 Sep 2018 08:58:29 +0000 (16:58 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 10 Sep 2018 09:17:47 +0000 (11:17 +0200)
commitc7f800ec9773d02a5b26faf77f829aa263226dc2
tree811e01e44a2d714a077e25ff7a24411b85987151
parent1f447e51c0b9e8beeec0917ea5f51930f55e17c9
staging: rtl8188eu: Fix two sleep-in-atomic-context bugs in rtw_chk_hi_queue_cmd()

usb_write_port_complete() in usb_ops_linux.c is a completion handler
function for the USB driver. So it should not sleep, but it is can sleep
according to the function call paths (from bottom to top) in Linux-4.16:

[FUNC] kzalloc(GFP_KERNEL)
drivers/staging/rtl8188eu/core/rtw_cmd.c, 1081:
kzalloc in rtw_chk_hi_queue_cmd
drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c, 604:
rtw_chk_hi_queue_cmd in usb_write_port_complete

[FUNC] kzalloc(GFP_KERNEL)
drivers/staging/rtl8188eu/core/rtw_cmd.c, 1075:
kzalloc in rtw_chk_hi_queue_cmd
drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c, 604:
rtw_chk_hi_queue_cmd in usb_write_port_complete

To fix these bugs, GFP_KERNEL is replaced with GFP_ATOMIC.

These bugs are 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_cmd.c