Commit 12f037ec authored by Bhaktipriya Shridhar's avatar Bhaktipriya Shridhar Committed by Greg Kroah-Hartman

staging: rtl8188eu: rtw_cmd: Clean up tests if NULL returned on failure

Some functions like kmalloc/kzalloc return NULL on failure.
When NULL represents failure, !x is commonly used.

This was done using Coccinelle:

@@
expression *e;
identifier l1;
@@

e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e
Signed-off-by: default avatarBhaktipriya Shridhar <bhaktipriya96@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4d97b691
...@@ -258,11 +258,11 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, ...@@ -258,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); rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1);
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
if (ph2c == NULL) if (!ph2c)
return _FAIL; return _FAIL;
psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC); psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC);
if (psurveyPara == NULL) { if (!psurveyPara) {
kfree(ph2c); kfree(ph2c);
return _FAIL; return _FAIL;
} }
...@@ -345,7 +345,7 @@ u8 rtw_createbss_cmd(struct adapter *padapter) ...@@ -345,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)); 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); pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (pcmd == NULL) { if (!pcmd) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
...@@ -516,7 +516,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu ...@@ -516,7 +516,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
/* prepare cmd parameter */ /* prepare cmd parameter */
param = kzalloc(sizeof(*param), GFP_KERNEL); param = kzalloc(sizeof(*param), GFP_KERNEL);
if (param == NULL) { if (!param) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
...@@ -525,7 +525,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu ...@@ -525,7 +525,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
if (enqueue) { if (enqueue) {
/* need enqueue, prepare cmd_obj and enqueue */ /* need enqueue, prepare cmd_obj and enqueue */
cmdobj = kzalloc(sizeof(*cmdobj), GFP_KERNEL); cmdobj = kzalloc(sizeof(*cmdobj), GFP_KERNEL);
if (cmdobj == NULL) { if (!cmdobj) {
res = _FAIL; res = _FAIL;
kfree(param); kfree(param);
goto exit; goto exit;
...@@ -624,20 +624,20 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue) ...@@ -624,20 +624,20 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue)
clear_cam_entry(padapter, entry); clear_cam_entry(padapter, entry);
} else { } else {
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
if (ph2c == NULL) { if (!ph2c) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_ATOMIC); psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_ATOMIC);
if (psetstakey_para == NULL) { if (!psetstakey_para) {
kfree(ph2c); kfree(ph2c);
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp), GFP_ATOMIC); psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp), GFP_ATOMIC);
if (psetstakey_rsp == NULL) { if (!psetstakey_rsp) {
kfree(ph2c); kfree(ph2c);
kfree(psetstakey_para); kfree(psetstakey_para);
res = _FAIL; res = _FAIL;
...@@ -671,13 +671,13 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) ...@@ -671,13 +671,13 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr)
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (ph2c == NULL) { if (!ph2c) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_KERNEL); paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_KERNEL);
if (paddbareq_parm == NULL) { if (!paddbareq_parm) {
kfree(ph2c); kfree(ph2c);
res = _FAIL; res = _FAIL;
goto exit; goto exit;
...@@ -708,13 +708,13 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter) ...@@ -708,13 +708,13 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter)
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
if (ph2c == NULL) { if (!ph2c) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
if (pdrvextra_cmd_parm == NULL) { if (!pdrvextra_cmd_parm) {
kfree(ph2c); kfree(ph2c);
res = _FAIL; res = _FAIL;
goto exit; goto exit;
...@@ -752,7 +752,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue) ...@@ -752,7 +752,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue)
/* prepare cmd parameter */ /* prepare cmd parameter */
setChannelPlan_param = kzalloc(sizeof(struct SetChannelPlan_param), GFP_KERNEL); setChannelPlan_param = kzalloc(sizeof(struct SetChannelPlan_param), GFP_KERNEL);
if (setChannelPlan_param == NULL) { if (!setChannelPlan_param) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
...@@ -761,7 +761,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue) ...@@ -761,7 +761,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue)
if (enqueue) { if (enqueue) {
/* need enqueue, prepare cmd_obj and enqueue */ /* need enqueue, prepare cmd_obj and enqueue */
pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (pcmdobj == NULL) { if (!pcmdobj) {
kfree(setChannelPlan_param); kfree(setChannelPlan_param);
res = _FAIL; res = _FAIL;
goto exit; goto exit;
...@@ -920,13 +920,13 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue) ...@@ -920,13 +920,13 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue)
if (enqueue) { if (enqueue) {
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
if (ph2c == NULL) { if (!ph2c) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
if (pdrvextra_cmd_parm == NULL) { if (!pdrvextra_cmd_parm) {
kfree(ph2c); kfree(ph2c);
res = _FAIL; res = _FAIL;
goto exit; goto exit;
...@@ -963,13 +963,13 @@ u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time) ...@@ -963,13 +963,13 @@ u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time)
u8 res = _SUCCESS; u8 res = _SUCCESS;
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
if (ph2c == NULL) { if (!ph2c) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
if (pdrvextra_cmd_parm == NULL) { if (!pdrvextra_cmd_parm) {
kfree(ph2c); kfree(ph2c);
res = _FAIL; res = _FAIL;
goto exit; goto exit;
...@@ -1005,13 +1005,13 @@ u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue) ...@@ -1005,13 +1005,13 @@ u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue)
if (enqueue) { if (enqueue) {
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (ph2c == NULL) { if (!ph2c) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL); pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL);
if (pdrvextra_cmd_parm == NULL) { if (!pdrvextra_cmd_parm) {
kfree(ph2c); kfree(ph2c);
res = _FAIL; res = _FAIL;
goto exit; goto exit;
...@@ -1103,13 +1103,13 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter) ...@@ -1103,13 +1103,13 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter)
u8 res = _SUCCESS; u8 res = _SUCCESS;
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (ph2c == NULL) { if (!ph2c) {
res = _FAIL; res = _FAIL;
goto exit; goto exit;
} }
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL); pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL);
if (pdrvextra_cmd_parm == NULL) { if (!pdrvextra_cmd_parm) {
kfree(ph2c); kfree(ph2c);
res = _FAIL; res = _FAIL;
goto exit; goto exit;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment