aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Senna Tschudin <peter.senna@gmail.com>2012-10-05 08:10:52 -0400
committerDavid S. Miller <davem@davemloft.net>2012-10-07 14:37:11 -0400
commit691299201b1416e823bbada0df316c6408167aa7 (patch)
tree71fb67f753c56a151ae2da863e104b3a22beea49
parent86e506e39909d356ca1c76c00022f3c64f5b7665 (diff)
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: Peter Senna Tschudin <peter.senna@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/amd/au1000_eth.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index 397596b078d9..f195acfa2df7 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -1174,8 +1174,10 @@ static int __devinit au1000_probe(struct platform_device *pdev)
1174 snprintf(aup->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", 1174 snprintf(aup->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
1175 pdev->name, aup->mac_id); 1175 pdev->name, aup->mac_id);
1176 aup->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); 1176 aup->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
1177 if (aup->mii_bus->irq == NULL) 1177 if (aup->mii_bus->irq == NULL) {
1178 err = -ENOMEM;
1178 goto err_out; 1179 goto err_out;
1180 }
1179 1181
1180 for (i = 0; i < PHY_MAX_ADDR; ++i) 1182 for (i = 0; i < PHY_MAX_ADDR; ++i)
1181 aup->mii_bus->irq[i] = PHY_POLL; 1183 aup->mii_bus->irq[i] = PHY_POLL;
@@ -1190,7 +1192,8 @@ static int __devinit au1000_probe(struct platform_device *pdev)
1190 goto err_mdiobus_reg; 1192 goto err_mdiobus_reg;
1191 } 1193 }
1192 1194
1193 if (au1000_mii_probe(dev) != 0) 1195 err = au1000_mii_probe(dev);
1196 if (err != 0)
1194 goto err_out; 1197 goto err_out;
1195 1198
1196 pDBfree = NULL; 1199 pDBfree = NULL;
@@ -1205,6 +1208,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)
1205 } 1208 }
1206 aup->pDBfree = pDBfree; 1209 aup->pDBfree = pDBfree;
1207 1210
1211 err = -ENODEV;
1208 for (i = 0; i < NUM_RX_DMA; i++) { 1212 for (i = 0; i < NUM_RX_DMA; i++) {
1209 pDB = au1000_GetFreeDB(aup); 1213 pDB = au1000_GetFreeDB(aup);
1210 if (!pDB) 1214 if (!pDB)
@@ -1213,6 +1217,8 @@ static int __devinit au1000_probe(struct platform_device *pdev)
1213 aup->rx_dma_ring[i]->buff_stat = (unsigned)pDB->dma_addr; 1217 aup->rx_dma_ring[i]->buff_stat = (unsigned)pDB->dma_addr;
1214 aup->rx_db_inuse[i] = pDB; 1218 aup->rx_db_inuse[i] = pDB;
1215 } 1219 }
1220
1221 err = -ENODEV;
1216 for (i = 0; i < NUM_TX_DMA; i++) { 1222 for (i = 0; i < NUM_TX_DMA; i++) {
1217 pDB = au1000_GetFreeDB(aup); 1223 pDB = au1000_GetFreeDB(aup);
1218 if (!pDB) 1224 if (!pDB)