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

drivers/usb/gadget/s3c-hsotg.c: fix error return code

Convert a 0 error return code to a negative one, as returned elsewhere in the
function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier ret;
expression e,e1,e2,e3,e4,x;
@@

(
if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
|
ret = 0
)
... when != ret = e1
*x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
... when != x = e2
when != ret = e3
*if (x == NULL || ...)
{
... when != ret = e4
* return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Julia Lawall and committed by
Greg Kroah-Hartman
dfdda5a0 fd4d72cb

+3
+3
drivers/usb/gadget/s3c-hsotg.c
··· 3599 3599 3600 3600 if (hsotg->num_of_eps == 0) { 3601 3601 dev_err(dev, "wrong number of EPs (zero)\n"); 3602 + ret = -EINVAL; 3602 3603 goto err_supplies; 3603 3604 } 3604 3605 ··· 3607 3606 GFP_KERNEL); 3608 3607 if (!eps) { 3609 3608 dev_err(dev, "cannot get memory\n"); 3609 + ret = -ENOMEM; 3610 3610 goto err_supplies; 3611 3611 } 3612 3612 ··· 3624 3622 GFP_KERNEL); 3625 3623 if (!hsotg->ctrl_req) { 3626 3624 dev_err(dev, "failed to allocate ctrl req\n"); 3625 + ret = -ENOMEM; 3627 3626 goto err_ep_mem; 3628 3627 } 3629 3628