提交 69129920 编写于 作者: P Peter Senna Tschudin 提交者: David S. Miller

drivers/net/ethernet/amd/au1000_eth.c: fix error return code

The function au1000_probe() return 0 for success and negative value
for most of its internal tests failures. There are exceptions
that are error cases going to err_out:. For this cases, the
function abort its success execution path, but returns non negative
value, making it dificult for a caller function to notice the error.

This patch fixes the error cases that do not return negative values.

This was found by Coccinelle, but the code change was made by hand.
This patch is not robot generated.

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

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}
// </smpl>
Signed-off-by: NPeter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 86e506e3
...@@ -1174,8 +1174,10 @@ static int __devinit au1000_probe(struct platform_device *pdev) ...@@ -1174,8 +1174,10 @@ static int __devinit au1000_probe(struct platform_device *pdev)
snprintf(aup->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", snprintf(aup->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
pdev->name, aup->mac_id); pdev->name, aup->mac_id);
aup->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); aup->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
if (aup->mii_bus->irq == NULL) if (aup->mii_bus->irq == NULL) {
err = -ENOMEM;
goto err_out; goto err_out;
}
for (i = 0; i < PHY_MAX_ADDR; ++i) for (i = 0; i < PHY_MAX_ADDR; ++i)
aup->mii_bus->irq[i] = PHY_POLL; aup->mii_bus->irq[i] = PHY_POLL;
...@@ -1190,7 +1192,8 @@ static int __devinit au1000_probe(struct platform_device *pdev) ...@@ -1190,7 +1192,8 @@ static int __devinit au1000_probe(struct platform_device *pdev)
goto err_mdiobus_reg; goto err_mdiobus_reg;
} }
if (au1000_mii_probe(dev) != 0) err = au1000_mii_probe(dev);
if (err != 0)
goto err_out; goto err_out;
pDBfree = NULL; pDBfree = NULL;
...@@ -1205,6 +1208,7 @@ static int __devinit au1000_probe(struct platform_device *pdev) ...@@ -1205,6 +1208,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)
} }
aup->pDBfree = pDBfree; aup->pDBfree = pDBfree;
err = -ENODEV;
for (i = 0; i < NUM_RX_DMA; i++) { for (i = 0; i < NUM_RX_DMA; i++) {
pDB = au1000_GetFreeDB(aup); pDB = au1000_GetFreeDB(aup);
if (!pDB) if (!pDB)
...@@ -1213,6 +1217,8 @@ static int __devinit au1000_probe(struct platform_device *pdev) ...@@ -1213,6 +1217,8 @@ static int __devinit au1000_probe(struct platform_device *pdev)
aup->rx_dma_ring[i]->buff_stat = (unsigned)pDB->dma_addr; aup->rx_dma_ring[i]->buff_stat = (unsigned)pDB->dma_addr;
aup->rx_db_inuse[i] = pDB; aup->rx_db_inuse[i] = pDB;
} }
err = -ENODEV;
for (i = 0; i < NUM_TX_DMA; i++) { for (i = 0; i < NUM_TX_DMA; i++) {
pDB = au1000_GetFreeDB(aup); pDB = au1000_GetFreeDB(aup);
if (!pDB) if (!pDB)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册