staging: rtl8712: rtl871x_mlme: Clean up tests if NULL returned on failure
authorBhaktipriya Shridhar <bhaktipriya96@gmail.com>
Sun, 20 Mar 2016 20:39:17 +0000 (02:09 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Mar 2016 14:30:36 +0000 (07:30 -0700)
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>
drivers/staging/rtl8712/rtl871x_mlme.c

index 62d4ae85af15aabcd6316c99c64948f498456652..f8b1c896019259223fde8e0861a2855531ff916a 100644 (file)
@@ -1205,7 +1205,7 @@ sint r8712_set_auth(struct _adapter *adapter,
                return _FAIL;
 
        psetauthparm = kzalloc(sizeof(*psetauthparm), GFP_ATOMIC);
-       if (psetauthparm == NULL) {
+       if (!psetauthparm) {
                kfree(pcmd);
                return _FAIL;
        }
@@ -1234,7 +1234,7 @@ sint r8712_set_key(struct _adapter *adapter,
        if (!pcmd)
                return _FAIL;
        psetkeyparm = kzalloc(sizeof(*psetkeyparm), GFP_ATOMIC);
-       if (psetkeyparm == NULL) {
+       if (!psetkeyparm) {
                ret = _FAIL;
                goto err_free_cmd;
        }