]> git.proxmox.com Git - mirror_ubuntu-jammy-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)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 17 Oct 2022 09:56:39 +0000 (11:56 +0200)
commitb150bdc281dcdc3ed75cb6d158dcbe448649ea8e
treef03ebe61785b108e4532397bd7d50ed42509c55c
parentc197fad4af8c1c55242da8f4590e85a15be6aab3
staging: rtl8192u: Fix sleep in atomic context bug in dm_fsync_timer_callback

BugLink: https://bugs.launchpad.net/bugs/1990162
[ Upstream commit 6a0c054930d554ad8f8044ef1fc856d9da391c81 ]

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: 8fc8598e61f6 ("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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/staging/rtl8192u/r8192U.h
drivers/staging/rtl8192u/r8192U_dm.c
drivers/staging/rtl8192u/r8192U_dm.h