staging: rtl8188eu: core: rtw_mlme: 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: Bhaktipriya Shridhar <bhaktipriya96@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
a703f47265
commit
6e9aeda3fa
|
@ -1579,13 +1579,13 @@ int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv)
|
||||||
int res = _SUCCESS;
|
int res = _SUCCESS;
|
||||||
|
|
||||||
pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
|
pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
|
||||||
if (pcmd == NULL) {
|
if (!pcmd) {
|
||||||
res = _FAIL; /* try again */
|
res = _FAIL; /* try again */
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
psetauthparm = kzalloc(sizeof(struct setauth_parm), GFP_KERNEL);
|
psetauthparm = kzalloc(sizeof(struct setauth_parm), GFP_KERNEL);
|
||||||
if (psetauthparm == NULL) {
|
if (!psetauthparm) {
|
||||||
kfree(pcmd);
|
kfree(pcmd);
|
||||||
res = _FAIL;
|
res = _FAIL;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -1616,11 +1616,11 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in
|
||||||
int res = _SUCCESS;
|
int res = _SUCCESS;
|
||||||
|
|
||||||
pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
|
pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
|
||||||
if (pcmd == NULL)
|
if (!pcmd)
|
||||||
return _FAIL; /* try again */
|
return _FAIL; /* try again */
|
||||||
|
|
||||||
psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL);
|
psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL);
|
||||||
if (psetkeyparm == NULL) {
|
if (!psetkeyparm) {
|
||||||
res = _FAIL;
|
res = _FAIL;
|
||||||
goto err_free_cmd;
|
goto err_free_cmd;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue