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

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

Some functions like 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 12f037ec
...@@ -4289,12 +4289,12 @@ void report_survey_event(struct adapter *padapter, ...@@ -4289,12 +4289,12 @@ void report_survey_event(struct adapter *padapter,
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
if (pcmd_obj == NULL) if (!pcmd_obj)
return; return;
cmdsz = sizeof(struct survey_event) + sizeof(struct C2HEvent_Header); cmdsz = sizeof(struct survey_event) + sizeof(struct C2HEvent_Header);
pevtcmd = kzalloc(cmdsz, GFP_ATOMIC); pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
if (pevtcmd == NULL) { if (!pevtcmd) {
kfree(pcmd_obj); kfree(pcmd_obj);
return; return;
} }
...@@ -4341,12 +4341,12 @@ void report_surveydone_event(struct adapter *padapter) ...@@ -4341,12 +4341,12 @@ void report_surveydone_event(struct adapter *padapter)
struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (pcmd_obj == NULL) if (!pcmd_obj)
return; return;
cmdsz = sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header); cmdsz = sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header);
pevtcmd = kzalloc(cmdsz, GFP_KERNEL); pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
if (pevtcmd == NULL) { if (!pevtcmd) {
kfree(pcmd_obj); kfree(pcmd_obj);
return; return;
} }
...@@ -4387,12 +4387,12 @@ void report_join_res(struct adapter *padapter, int res) ...@@ -4387,12 +4387,12 @@ void report_join_res(struct adapter *padapter, int res)
struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
if (pcmd_obj == NULL) if (!pcmd_obj)
return; return;
cmdsz = sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header); cmdsz = sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header);
pevtcmd = kzalloc(cmdsz, GFP_ATOMIC); pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
if (pevtcmd == NULL) { if (!pevtcmd) {
kfree(pcmd_obj); kfree(pcmd_obj);
return; return;
} }
...@@ -4440,12 +4440,12 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi ...@@ -4440,12 +4440,12 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi
struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (pcmd_obj == NULL) if (!pcmd_obj)
return; return;
cmdsz = sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header); cmdsz = sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header);
pevtcmd = kzalloc(cmdsz, GFP_KERNEL); pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
if (pevtcmd == NULL) { if (!pevtcmd) {
kfree(pcmd_obj); kfree(pcmd_obj);
return; return;
} }
...@@ -4495,12 +4495,12 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int ...@@ -4495,12 +4495,12 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int
struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
if (pcmd_obj == NULL) if (!pcmd_obj)
return; return;
cmdsz = sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header); cmdsz = sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header);
pevtcmd = kzalloc(cmdsz, GFP_KERNEL); pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
if (pevtcmd == NULL) { if (!pevtcmd) {
kfree(pcmd_obj); kfree(pcmd_obj);
return; return;
} }
...@@ -4911,11 +4911,11 @@ void survey_timer_hdl(unsigned long data) ...@@ -4911,11 +4911,11 @@ void survey_timer_hdl(unsigned long data)
} }
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
if (ph2c == NULL) if (!ph2c)
goto exit_survey_timer_hdl; goto exit_survey_timer_hdl;
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);
goto exit_survey_timer_hdl; goto exit_survey_timer_hdl;
} }
...@@ -5479,7 +5479,7 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) ...@@ -5479,7 +5479,7 @@ u8 set_tx_beacon_cmd(struct adapter *padapter)
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;
} }
......
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