staging: rtl8188eu: always free cmd_obj in the cmd thread
authorMartin Kaiser <martin@kaiser.cx>
Thu, 8 Apr 2021 19:55:58 +0000 (21:55 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 Apr 2021 14:17:23 +0000 (16:17 +0200)
The rtl8188 driver starts a command thread that reads commands from a queue
and processes them. Each command consists of a struct cmd_obj. The command
thread may call a function to process the current command and optionally a
post-processing function. Eventually, the command's cmd_obj must be freed.

At the moment, if there's a post-processing function for the current
command, this function has to free the cmd_obj. If there's no
post-processing function, the command thread frees cmd_obj.

It's much simpler if we always leave it to the command thread to free
cmd_obj.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20210408195601.4762-9-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8188eu/core/rtw_cmd.c

index 0bbe5ee..4e4cac1 100644 (file)
@@ -235,17 +235,16 @@ _next:
                                RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
                                         ("mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n",
                                          pcmd_callback, pcmd->cmdcode));
-                               rtw_free_cmd_obj(pcmd);
                        } else {
                                /* todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!= NULL) */
-                               pcmd_callback(pcmd->padapter, pcmd);/* need consider that free cmd_obj in rtw_cmd_callback */
+                               pcmd_callback(pcmd->padapter, pcmd);
                        }
                } else {
                        RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
                                 ("%s: cmdcode = 0x%x callback not defined!\n",
                                  __func__, pcmd->cmdcode));
-                       rtw_free_cmd_obj(pcmd);
                }
+               rtw_free_cmd_obj(pcmd);
 
                if (signal_pending(current))
                        flush_signals(current);
@@ -1186,9 +1185,6 @@ void rtw_survey_cmd_callback(struct adapter *padapter,  struct cmd_obj *pcmd)
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
                         ("\n ********Error: MgntActrtw_set_802_11_bssid_LIST_SCAN Fail ************\n\n."));
        }
-
-       /*  free cmd */
-       rtw_free_cmd_obj(pcmd);
 }
 
 void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
@@ -1202,11 +1198,7 @@ void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
 
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
                         ("\n ***Error: disconnect_cmd_callback Fail ***\n."));
-               return;
        }
-
-       /*  free cmd */
-       rtw_free_cmd_obj(pcmd);
 }
 
 void rtw_joinbss_cmd_callback(struct adapter *padapter,  struct cmd_obj *pcmd)
@@ -1224,8 +1216,6 @@ void rtw_joinbss_cmd_callback(struct adapter *padapter,  struct cmd_obj *pcmd)
                mod_timer(&pmlmepriv->assoc_timer,
                          jiffies + msecs_to_jiffies(1));
        }
-
-       rtw_free_cmd_obj(pcmd);
 }
 
 void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
@@ -1292,8 +1282,6 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
 createbss_cmd_fail:
 
        spin_unlock_bh(&pmlmepriv->lock);
-
-       rtw_free_cmd_obj(pcmd);
 }
 
 void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj *pcmd)
@@ -1305,10 +1293,7 @@ void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj *pc
        if (!psta) {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
                         ("\nERROR: %s => can't get sta_info\n\n", __func__));
-               goto exit;
        }
-exit:
-       rtw_free_cmd_obj(pcmd);
 }
 
 void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj *pcmd)
@@ -1322,7 +1307,7 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj *
        if (!psta) {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
                         ("\nERROR: %s => can't get sta_info\n\n", __func__));
-               goto exit;
+               return;
        }
 
        psta->aid = passocsta_rsp->cam_id;
@@ -1332,7 +1317,4 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj *
 
        set_fwstate(pmlmepriv, _FW_LINKED);
        spin_unlock_bh(&pmlmepriv->lock);
-
-exit:
-       rtw_free_cmd_obj(pcmd);
 }