Skip to content

Commit

Permalink
drivers/usb/host/ehci-platform.c: fix error return code
Browse files Browse the repository at this point in the history
Convert a possibly 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>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Julia Lawall authored and Greg Kroah-Hartman committed Aug 15, 2012
1 parent 4728250 commit ec03ad8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/host/ehci-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ static int __devinit ehci_platform_probe(struct platform_device *dev)
}

hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
if (!hcd->regs)
if (!hcd->regs) {
err = -ENOMEM;
goto err_release_region;
}
err = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (err)
goto err_iounmap;
Expand Down

0 comments on commit ec03ad8

Please sign in to comment.