Skip to content

Commit

Permalink
drivers/net/ethernet/freescale/fs_enet: fix error return code
Browse files Browse the repository at this point in the history
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: David S. Miller <davem@davemloft.net>
  • Loading branch information
Julia Lawall authored and David S. Miller committed Aug 15, 2012
1 parent f37c54b commit 137bc99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev)

new_bus->phy_mask = ~0;
new_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
if (!new_bus->irq)
if (!new_bus->irq) {
ret = -ENOMEM;
goto out_unmap_regs;
}

new_bus->parent = &ofdev->dev;
dev_set_drvdata(&ofdev->dev, new_bus);
Expand Down
8 changes: 6 additions & 2 deletions drivers/net/ethernet/freescale/fs_enet/mii-fec.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev)
snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", res.start);

fec->fecp = ioremap(res.start, resource_size(&res));
if (!fec->fecp)
if (!fec->fecp) {
ret = -ENOMEM;
goto out_fec;
}

if (get_bus_freq) {
clock = get_bus_freq(ofdev->dev.of_node);
Expand Down Expand Up @@ -172,8 +174,10 @@ static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev)

new_bus->phy_mask = ~0;
new_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
if (!new_bus->irq)
if (!new_bus->irq) {
ret = -ENOMEM;
goto out_unmap_regs;
}

new_bus->parent = &ofdev->dev;
dev_set_drvdata(&ofdev->dev, new_bus);
Expand Down

0 comments on commit 137bc99

Please sign in to comment.