staging: rtl8188eu: rtw_cmd: Clean up tests if NULL returned on failure
[cascardo/linux.git] / drivers / staging / rtl8188eu / core / rtw_cmd.c
index e5a6b7a..7748523 100644 (file)
  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  * more details.
  *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- *
  ******************************************************************************/
 #define _RTW_CMD_C_
 
@@ -263,11 +258,11 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct ndis_802_11_ssid *ssid,
                rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1);
 
        ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
-       if (ph2c == NULL)
+       if (!ph2c)
                return _FAIL;
 
        psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC);
-       if (psurveyPara == NULL) {
+       if (!psurveyPara) {
                kfree(ph2c);
                return _FAIL;
        }
@@ -350,7 +345,7 @@ u8 rtw_createbss_cmd(struct adapter  *padapter)
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid));
 
        pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
-       if (pcmd == NULL) {
+       if (!pcmd) {
                res = _FAIL;
                goto exit;
        }
@@ -521,7 +516,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
 
        /* prepare cmd parameter */
        param = kzalloc(sizeof(*param), GFP_KERNEL);
-       if (param == NULL) {
+       if (!param) {
                res = _FAIL;
                goto exit;
        }
@@ -530,7 +525,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
        if (enqueue) {
                /* need enqueue, prepare cmd_obj and enqueue */
                cmdobj = kzalloc(sizeof(*cmdobj), GFP_KERNEL);
-               if (cmdobj == NULL) {
+               if (!cmdobj) {
                        res = _FAIL;
                        kfree(param);
                        goto exit;
@@ -629,20 +624,20 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue)
                clear_cam_entry(padapter, entry);
        } else {
                ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
-               if (ph2c == NULL) {
+               if (!ph2c) {
                        res = _FAIL;
                        goto exit;
                }
 
                psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_ATOMIC);
-               if (psetstakey_para == NULL) {
+               if (!psetstakey_para) {
                        kfree(ph2c);
                        res = _FAIL;
                        goto exit;
                }
 
                psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp), GFP_ATOMIC);
-               if (psetstakey_rsp == NULL) {
+               if (!psetstakey_rsp) {
                        kfree(ph2c);
                        kfree(psetstakey_para);
                        res = _FAIL;
@@ -676,13 +671,13 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr)
 
 
        ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
-       if (ph2c == NULL) {
+       if (!ph2c) {
                res = _FAIL;
                goto exit;
        }
 
        paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_KERNEL);
-       if (paddbareq_parm == NULL) {
+       if (!paddbareq_parm) {
                kfree(ph2c);
                res = _FAIL;
                goto exit;
@@ -713,13 +708,13 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter)
 
 
        ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
-       if (ph2c == NULL) {
+       if (!ph2c) {
                res = _FAIL;
                goto exit;
        }
 
        pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
-       if (pdrvextra_cmd_parm == NULL) {
+       if (!pdrvextra_cmd_parm) {
                kfree(ph2c);
                res = _FAIL;
                goto exit;
@@ -757,7 +752,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue)
 
        /* prepare cmd parameter */
        setChannelPlan_param = kzalloc(sizeof(struct SetChannelPlan_param), GFP_KERNEL);
-       if (setChannelPlan_param == NULL) {
+       if (!setChannelPlan_param) {
                res = _FAIL;
                goto exit;
        }
@@ -766,7 +761,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue)
        if (enqueue) {
                /* need enqueue, prepare cmd_obj and enqueue */
                pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
-               if (pcmdobj == NULL) {
+               if (!pcmdobj) {
                        kfree(setChannelPlan_param);
                        res = _FAIL;
                        goto exit;
@@ -925,13 +920,13 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue)
 
        if (enqueue) {
                ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
-               if (ph2c == NULL) {
+               if (!ph2c) {
                        res = _FAIL;
                        goto exit;
                }
 
                pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
-               if (pdrvextra_cmd_parm == NULL) {
+               if (!pdrvextra_cmd_parm) {
                        kfree(ph2c);
                        res = _FAIL;
                        goto exit;
@@ -968,13 +963,13 @@ u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time)
        u8      res = _SUCCESS;
 
        ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
-       if (ph2c == NULL) {
+       if (!ph2c) {
                res = _FAIL;
                goto exit;
        }
 
        pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
-       if (pdrvextra_cmd_parm == NULL) {
+       if (!pdrvextra_cmd_parm) {
                kfree(ph2c);
                res = _FAIL;
                goto exit;
@@ -1010,13 +1005,13 @@ u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue)
 
        if (enqueue) {
                ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
-               if (ph2c == NULL) {
+               if (!ph2c) {
                        res = _FAIL;
                        goto exit;
                }
 
                pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL);
-               if (pdrvextra_cmd_parm == NULL) {
+               if (!pdrvextra_cmd_parm) {
                        kfree(ph2c);
                        res = _FAIL;
                        goto exit;
@@ -1108,13 +1103,13 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter)
        u8      res = _SUCCESS;
 
        ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
-       if (ph2c == NULL) {
+       if (!ph2c) {
                res = _FAIL;
                goto exit;
        }
 
        pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL);
-       if (pdrvextra_cmd_parm == NULL) {
+       if (!pdrvextra_cmd_parm) {
                kfree(ph2c);
                res = _FAIL;
                goto exit;