]> git.baikalelectronics.ru Git - kernel.git/commit
staging: rtl8192u: Fix sleep in atomic context bug in dm_fsync_timer_callback
authorDuoming Zhou <duoming@zju.edu.cn>
Sun, 10 Jul 2022 10:30:02 +0000 (18:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:23:50 +0000 (14:23 +0200)
commit488ab3f9bc01b2c12a0789cc0ec7e16287d24498
tree2710da20ab023e2cb6dbd910ee56f77d6262fca2
parent8a7b8ebbb38f13e13647c813f67c292b93e0f06f
staging: rtl8192u: Fix sleep in atomic context bug in dm_fsync_timer_callback

[ Upstream commit d0481f4d76f877fab8ff0e1f87738347f5b3685c ]

There are sleep in atomic context bugs when dm_fsync_timer_callback is
executing. The root cause is that the memory allocation functions with
GFP_KERNEL or GFP_NOIO parameters are called in dm_fsync_timer_callback
which is a timer handler. The call paths that could trigger bugs are
shown below:

    (interrupt context)
dm_fsync_timer_callback
  write_nic_byte
    kzalloc(sizeof(data), GFP_KERNEL); //may sleep
    usb_control_msg
      kmalloc(.., GFP_NOIO); //may sleep
  write_nic_dword
    kzalloc(sizeof(data), GFP_KERNEL); //may sleep
    usb_control_msg
      kmalloc(.., GFP_NOIO); //may sleep

This patch uses delayed work to replace timer and moves the operations
that may sleep into the delayed work in order to mitigate bugs.

Fixes: 33d35d972f59 ("Staging: Added Realtek rtl8192u driver to staging")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Link: https://lore.kernel.org/r/20220710103002.63283-1-duoming@zju.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/staging/rtl8192u/r8192U.h
drivers/staging/rtl8192u/r8192U_dm.c
drivers/staging/rtl8192u/r8192U_dm.h