Commit 7cf51d34 authored by simran singhal's avatar simran singhal Committed by Greg Kroah-Hartman

staging: vpfe_mc_capture: 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: default avatarsimran singhal <singhalsimran0@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1e8b15d0
...@@ -228,7 +228,7 @@ static int vpfe_enable_clock(struct vpfe_device *vpfe_dev) ...@@ -228,7 +228,7 @@ static int vpfe_enable_clock(struct vpfe_device *vpfe_dev)
vpfe_dev->clks = kcalloc(vpfe_cfg->num_clocks, vpfe_dev->clks = kcalloc(vpfe_cfg->num_clocks,
sizeof(*vpfe_dev->clks), GFP_KERNEL); sizeof(*vpfe_dev->clks), GFP_KERNEL);
if (vpfe_dev->clks == NULL) if (!vpfe_dev->clks)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < vpfe_cfg->num_clocks; i++) { for (i = 0; i < vpfe_cfg->num_clocks; i++) {
...@@ -348,7 +348,7 @@ static int register_i2c_devices(struct vpfe_device *vpfe_dev) ...@@ -348,7 +348,7 @@ static int register_i2c_devices(struct vpfe_device *vpfe_dev)
vpfe_dev->sd = vpfe_dev->sd =
kcalloc(num_subdevs, sizeof(struct v4l2_subdev *), kcalloc(num_subdevs, sizeof(struct v4l2_subdev *),
GFP_KERNEL); GFP_KERNEL);
if (vpfe_dev->sd == NULL) if (!vpfe_dev->sd)
return -ENOMEM; return -ENOMEM;
for (i = 0, k = 0; i < num_subdevs; i++) { for (i = 0, k = 0; i < num_subdevs; i++) {
......
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