Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: rtl8712: fix race condition

In probe function, request_firmware_nowait() is called to load firmware
asynchronously. At completion of firmware loading, register_netdev() is
called. However, a mutex needed by netdev is initialized after the call
to request_firmware_nowait(). Consequently, it can happen that
register_netdev() is called before the driver is ready.

Move the mutex initialization into r8712_init_drv_sw(), which is called
before request_firmware_nowait().

Reported-by: syzbot+b08315e8cf5a78eed03c@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-staging/000000000000d9d4560601b8e0d7@google.com/T/#u
Fixes: 8c213fa59199 ("staging: r8712u: Use asynchronous firmware loading")
Cc: stable <stable@kernel.org>
Signed-off-by: Nam Cao <namcaov@gmail.com>
Link: https://lore.kernel.org/r/20230731110620.116562-1-namcaov@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Nam Cao and committed by
Greg Kroah-Hartman
1422b526 ac19020b

+1 -1
+1
drivers/staging/rtl8712/os_intfs.c
··· 327 327 mp871xinit(padapter); 328 328 init_default_value(padapter); 329 329 r8712_InitSwLeds(padapter); 330 + mutex_init(&padapter->mutex_start); 330 331 331 332 return 0; 332 333
-1
drivers/staging/rtl8712/usb_intf.c
··· 567 567 if (rtl871x_load_fw(padapter)) 568 568 goto deinit_drv_sw; 569 569 init_completion(&padapter->rx_filter_ready); 570 - mutex_init(&padapter->mutex_start); 571 570 return 0; 572 571 573 572 deinit_drv_sw: