Skip to contentSkip to conversation

staging: r8188eu: Fix a couple scheduling in atomic bugs

PATCH In review Dan Carpenter 2 participants 2 messages Aug 12, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: r8188eu: Fix a couple scheduling in atomic bugs

These allocations are sometimes done while holding a spin_lock so they have to be atomic. The call tree looks like this:

-> rtw_set_802_11_connect() <- takes a spin_lock
-> rtw_do_join()

      -> rtw_sitesurvey_cmd()  <-- does a GFP_ATOMIC allocation
         -> p2p_ps_wk_cmd()
Fixes 15865124feed ("staging: r8188eu: introduce new core dir for RTL8188eu driver")
---
 drivers/staging/r8188eu/core/rtw_p2p.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/r8188eu/core/rtw_p2p.c +2 -2
index b4497444a7af..04480a86902e 100644
@@ -1697,13 +1697,13 @@ u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue)
 		return res;
 
 	if (enqueue) {
-		ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
+		ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
 		if (!ph2c) {
 			res = _FAIL;
 			goto exit;
 		}
 
-		pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL);
+		pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
 		if (!pdrvextra_cmd_parm) {
 			kfree(ph2c);
 			res = _FAIL;
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw
Quoted 24 lines · Dan Carpenter

These allocations are sometimes done while holding a spin_lock so they have to be atomic. The call tree looks like this:

-> rtw_set_802_11_connect() <- takes a spin_lock

    -> rtw_do_join()
       -> rtw_sitesurvey_cmd()  <-- does a GFP_ATOMIC allocation
          -> p2p_ps_wk_cmd()
Fixes 15865124feed ("staging: r8188eu: introduce new core dir for RTL8188eu driver")
---
  drivers/staging/r8188eu/core/rtw_p2p.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/r8188eu/core/rtw_p2p.c +1 -1
index b4497444a7af..04480a86902e 100644
@@ -1697,13 +1697,13 @@ u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue)
  		return res;
 
  	if (enqueue) {
-		ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
+		ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);

drivers/staging/r8188eu/core/rtw_p2p.c u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue) · line 1709

Quoted 10 lines
drivers/staging/r8188eu/core/rtw_p2p.c +1 -1
  		if (!ph2c) {
  			res = _FAIL;
  			goto exit;
  		}
 
-		pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL);
+		pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
  		if (!pdrvextra_cmd_parm) {
  			kfree(ph2c);
  			res = _FAIL;

Thanks,

Larry