Skip to contentSkip to conversation

drivers/net/ethernet/renesas/sh_eth.c: fix error return code

PATCH Applied Peter Senna Tschudin 2 participants 10 messages Oct 5, 2012 – Oct 7, 2012

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v2 16/20 drivers/net/ethernet/renesas/sh_eth.c: fix error return code

From: Peter Senna Tschudin <[email protected]>

The function sh_eth_drv_probe() return 0 for success and negative value for most of its internal tests failures. There is one exception that is error case going to out_release:. For this error case, the function abort its success execution path, but returns non negative value, making it difficult for a caller function to notice the error.

This patch fixes the error case that do not return negative value.

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>

---
Change from V1:
Updated commit message. See:
http://www.kernelhub.org/?p=2&msg9319

 drivers/net/ethernet/renesas/sh_eth.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/renesas/sh_eth.c +1 -0
index bad8f2e..c8bfea0 100644
@@ -2438,6 +2438,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 		rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 		if (!rtsu) {
 			dev_err(&pdev->dev, "Not found TSU resource\n");
+			ret = -ENODEV;
 			goto out_release;
 		}
 		mdp->tsu_addr = ioremap(rtsu->start,
#1 lore raw

PATCH v2 17/20 drivers/net/ethernet/sun/niu.c: fix error return code

From: Peter Senna Tschudin <[email protected]>

The function niu_pci_init_one() return 0 for success and negative value for most of its internal tests failures. There is one exception that is error case going to err_out_free_res:. For this error case, the function abort its success execution path, but returns non negative value, making it difficult for a caller function to notice the error.

This patch fixes the error case that do not return negative value.

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>

---
Change from V1:
Updated commit message. See:
http://www.kernelhub.org/?p=2&msg9319

 drivers/net/ethernet/sun/niu.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/sun/niu.c +1 -0
index 8419bf3..275b430 100644
@@ -9788,6 +9788,7 @@ static int __devinit niu_pci_init_one(struct pci_dev *pdev,
 
 	if (!pci_is_pcie(pdev)) {
 		dev_err(&pdev->dev, "Cannot find PCI Express capability, aborting\n");
+		err = -ENODEV;
 		goto err_out_free_res;
 	}
 
maintainer Applied
#2 lore raw

Re: [PATCH 17/20 V2] drivers/net/ethernet/sun/niu.c: fix error return code

Applied.

#3 lore raw

PATCH v2 18/20 drivers/net/ethernet/sun/sungem.c: fix error return code

In reply to Peter Senna Tschudin

From: Peter Senna Tschudin <[email protected]>

The function gem_init_one() return 0 for success and negative value for most of its internal tests failures. There is one exception that is error case going to err_out_free_consistent:. For this error case, the function abort its success execution path, but returns non negative value, making it difficult for a caller function to notice the error.

This patch fixes the error case that do not return negative value.

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>

---
Change from V1:
Updated commit message. See:
http://www.kernelhub.org/?p=2&msg9319

 drivers/net/ethernet/sun/sungem.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/sun/sungem.c +2 -1
index 9ae12d0..6c8695e 100644
@@ -2963,7 +2963,8 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
 		goto err_out_iounmap;
 	}
 
-	if (gem_get_device_address(gp))
+	err = gem_get_device_address(gp);
+	if (err)
 		goto err_out_free_consistent;
 
 	dev->netdev_ops = &gem_netdev_ops;
maintainer Applied
#4 lore raw

Re: [PATCH 18/20 V2] drivers/net/ethernet/sun/sungem.c: fix error return code

Applied.

#5 lore raw

PATCH v2 19/20 drivers/net/ethernet/marvell/skge.c: fix error return code

In reply to Peter Senna Tschudin

From: Peter Senna Tschudin <[email protected]>

The function skge_probe() return 0 for success and negative value for most of its internal tests failures. There is one exception that is error case going to err_out_led_off:. For this error case, the function abort its success execution path, but returns non negative value, making it difficult for a caller function to notice the error.

This patch fixes the error case that do not return negative value.

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>

---
Change from V1:
Updated commit message. See:
http://www.kernelhub.org/?p=2&msg9319

 drivers/net/ethernet/marvell/skge.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/skge.c +3 -1
index 5a30bf8..91836b5 100644
@@ -3945,8 +3945,10 @@ static int __devinit skge_probe(struct pci_dev *pdev,
 		skge_board_name(hw), hw->chip_rev);
 
 	dev = skge_devinit(hw, 0, using_dac);
-	if (!dev)
+	if (!dev) {
+		err = -ENOMEM;
 		goto err_out_led_off;
+	}
 
 	/* Some motherboards are broken and has zero in ROM. */
 	if (!is_valid_ether_addr(dev->dev_addr))
maintainer Applied
#6 lore raw

Re: [PATCH 19/20 V2] drivers/net/ethernet/marvell/skge.c: fix error return code

Applied.

#7 lore raw

PATCH v2 20/20 drivers/net/ethernet/marvell/sky2.c: fix error return code

In reply to Peter Senna Tschudin

From: Peter Senna Tschudin <[email protected]>

The function sky2_probe() return 0 for success and negative value for most of its internal tests failures. There are two exceptions that are error cases going to err_out*:. For this two 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>

---
Change from V1:
Updated commit message. See:
http://www.kernelhub.org/?p=2&msg9319

 drivers/net/ethernet/marvell/sky2.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/sky2.c +4 -1
index 2b0748d..78946fe 100644
@@ -4924,6 +4924,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
 
 	if (~reg = 0) {
 		dev_err(&pdev->dev, "PCI configuration read error\n");
+		err = -EIO;
 		goto err_out;
 	}
 
@@ -4993,8 +4994,10 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
 	hw->st_size = hw->ports * roundup_pow_of_two(3*RX_MAX_PENDING + TX_MAX_PENDING);
 	hw->st_le = pci_alloc_consistent(pdev, hw->st_size * sizeof(struct sky2_status_le),
 					 &hw->st_dma);
-	if (!hw->st_le)
+	if (!hw->st_le) {
+		err = -ENOMEM;
 		goto err_out_reset;
+	}
 
 	dev_info(&pdev->dev, "Yukon-2 %s chip revision %d\n",
 		 sky2_name(hw->chip_id, buf1, sizeof(buf1)), hw->chip_rev);
maintainer Applied
#8 lore raw

Re: [PATCH 20/20 V2] drivers/net/ethernet/marvell/sky2.c: fix error return code

Applied.