Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: rtl8712: rtl871x_ioctl_linux: 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>

authored by

Bhaktipriya Shridhar and committed by
Greg Kroah-Hartman
0b90c305 b1d05500

+2 -2
+2 -2
drivers/staging/rtl8712/rtl871x_ioctl_linux.c
··· 399 399 if (wep_key_len > 0) { 400 400 wep_key_len = wep_key_len <= 5 ? 5 : 13; 401 401 pwep = kzalloc(sizeof(*pwep), GFP_ATOMIC); 402 - if (pwep == NULL) 402 + if (!pwep) 403 403 return -ENOMEM; 404 404 pwep->KeyLength = wep_key_len; 405 405 pwep->Length = wep_key_len + ··· 1793 1793 1794 1794 param_len = sizeof(struct ieee_param) + pext->key_len; 1795 1795 param = kzalloc(param_len, GFP_ATOMIC); 1796 - if (param == NULL) 1796 + if (!param) 1797 1797 return -ENOMEM; 1798 1798 param->cmd = IEEE_CMD_SET_ENCRYPTION; 1799 1799 eth_broadcast_addr(param->sta_addr);