Skip to content

Commit 9be550e

Browse files
pskrgaggregkh
authored andcommitted
staging: rtl8712: get rid of flush_scheduled_work
This patch is preparation for following patch for error handling refactoring. flush_scheduled_work() takes (wq_completion)events lock and it can lead to deadlock when r871xu_dev_remove() is called from workqueue. To avoid deadlock sutiation we can change flush_scheduled_work() call to flush_work() call for all possibly scheduled works in this driver, since next patch adds device_release_driver() in case of fw load failure. Signed-off-by: Pavel Skripkin <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/6e028b4c457eeb7156c76c6ea3cdb3cb0207c7e1.1626895918.git.paskripkin@gmail.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent cb7abd1 commit 9be550e

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

drivers/staging/rtl8712/rtl8712_led.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,3 +1820,11 @@ void LedControl871x(struct _adapter *padapter, enum LED_CTL_MODE LedAction)
18201820
break;
18211821
}
18221822
}
1823+
1824+
void r8712_flush_led_works(struct _adapter *padapter)
1825+
{
1826+
struct led_priv *pledpriv = &padapter->ledpriv;
1827+
1828+
flush_work(&pledpriv->SwLed0.BlinkWorkItem);
1829+
flush_work(&pledpriv->SwLed1.BlinkWorkItem);
1830+
}

drivers/staging/rtl8712/rtl871x_led.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ struct led_priv {
112112
void r8712_InitSwLeds(struct _adapter *padapter);
113113
void r8712_DeInitSwLeds(struct _adapter *padapter);
114114
void LedControl871x(struct _adapter *padapter, enum LED_CTL_MODE LedAction);
115+
void r8712_flush_led_works(struct _adapter *padapter);
115116

116117
#endif
117118

drivers/staging/rtl8712/rtl871x_pwrctrl.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,11 @@ void r8712_unregister_cmd_alive(struct _adapter *padapter)
224224
}
225225
mutex_unlock(&pwrctrl->mutex_lock);
226226
}
227+
228+
void r8712_flush_rwctrl_works(struct _adapter *padapter)
229+
{
230+
struct pwrctrl_priv *pwrctrl = &padapter->pwrctrlpriv;
231+
232+
flush_work(&pwrctrl->SetPSModeWorkItem);
233+
flush_work(&pwrctrl->rpwm_workitem);
234+
}

drivers/staging/rtl8712/rtl871x_pwrctrl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,6 @@ void r8712_cpwm_int_hdl(struct _adapter *padapter,
108108
void r8712_set_ps_mode(struct _adapter *padapter, uint ps_mode,
109109
uint smart_ps);
110110
void r8712_set_rpwm(struct _adapter *padapter, u8 val8);
111+
void r8712_flush_rwctrl_works(struct _adapter *padapter);
111112

112113
#endif /* __RTL871X_PWRCTRL_H_ */

drivers/staging/rtl8712/usb_intf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,8 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf)
606606
padapter->surprise_removed = true;
607607
if (pnetdev->reg_state != NETREG_UNINITIALIZED)
608608
unregister_netdev(pnetdev); /* will call netdev_close() */
609-
flush_scheduled_work();
609+
r8712_flush_rwctrl_works(padapter);
610+
r8712_flush_led_works(padapter);
610611
udelay(1);
611612
/* Stop driver mlme relation timer */
612613
r8712_stop_drv_timers(padapter);

0 commit comments

Comments
 (0)