staging: rtl8712: usb_ops_linux: Clean up tests if NULL returned on failure
authorBhaktipriya Shridhar <bhaktipriya96@gmail.com>
Sun, 20 Mar 2016 20:38:36 +0000 (02:08 +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/usb_ops_linux.c

index 454cdf6..6f12345 100644 (file)
@@ -504,7 +504,7 @@ int r8712_usbctrl_vendorreq(struct intf_priv *pintfpriv, u8 request, u16 value,
        u8 *palloc_buf, *pIo_buf;
 
        palloc_buf = kmalloc((u32)len + 16, GFP_ATOMIC);
-       if (palloc_buf == NULL)
+       if (!palloc_buf)
                return -ENOMEM;
        pIo_buf = palloc_buf + 16 - ((addr_t)(palloc_buf) & 0x0f);
        if (requesttype == 0x01) {