netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 16/20 V2] drivers/net/ethernet/renesas/sh_eth.c: fix error return code
@ 2012-10-05 22:40 Peter Senna Tschudin
  2012-10-05 22:40 ` [PATCH 17/20 V2] drivers/net/ethernet/sun/niu.c: " Peter Senna Tschudin
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 22:40 UTC (permalink / raw)
  To: davem
  Cc: yoshihiro.shimoda.uh, nobuhiro.iwamatsu.yj, netdev, linux-kernel,
	kernel-janitors, Peter Senna Tschudin

From: Peter Senna Tschudin <peter.senna@gmail.com>

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>

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---
Change from V1:
        Updated commit message. See:
        http://www.kernelhub.org/?p=2&msg=139319

 drivers/net/ethernet/renesas/sh_eth.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index bad8f2e..c8bfea0 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -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,

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 17/20 V2] drivers/net/ethernet/sun/niu.c: fix error return code
  2012-10-05 22:40 [PATCH 16/20 V2] drivers/net/ethernet/renesas/sh_eth.c: fix error return code Peter Senna Tschudin
@ 2012-10-05 22:40 ` Peter Senna Tschudin
  2012-10-07 18:39   ` David Miller
  2012-10-05 22:40 ` [PATCH 18/20 V2] drivers/net/ethernet/sun/sungem.c: " Peter Senna Tschudin
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 22:40 UTC (permalink / raw)
  To: davem
  Cc: mcarlson, eric.dumazet, mchan, shuah.khan, netdev, linux-kernel,
	kernel-janitors, Peter Senna Tschudin

From: Peter Senna Tschudin <peter.senna@gmail.com>

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>

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---
Change from V1:
        Updated commit message. See:
        http://www.kernelhub.org/?p=2&msg=139319

 drivers/net/ethernet/sun/niu.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 8419bf3..275b430 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -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;
 	}
 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 18/20 V2] drivers/net/ethernet/sun/sungem.c: fix error return code
  2012-10-05 22:40 [PATCH 16/20 V2] drivers/net/ethernet/renesas/sh_eth.c: fix error return code Peter Senna Tschudin
  2012-10-05 22:40 ` [PATCH 17/20 V2] drivers/net/ethernet/sun/niu.c: " Peter Senna Tschudin
@ 2012-10-05 22:40 ` Peter Senna Tschudin
  2012-10-07 18:39   ` David Miller
  2012-10-05 22:40 ` [PATCH 19/20 V2] drivers/net/ethernet/marvell/skge.c: " Peter Senna Tschudin
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 22:40 UTC (permalink / raw)
  To: davem
  Cc: jdmason, gerard.lledo, dhowells, joe, netdev, linux-kernel,
	kernel-janitors, Peter Senna Tschudin

From: Peter Senna Tschudin <peter.senna@gmail.com>

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>

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---
Change from V1:
        Updated commit message. See:
        http://www.kernelhub.org/?p=2&msg=139319

 drivers/net/ethernet/sun/sungem.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c
index 9ae12d0..6c8695e 100644
--- a/drivers/net/ethernet/sun/sungem.c
+++ b/drivers/net/ethernet/sun/sungem.c
@@ -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;

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 19/20 V2] drivers/net/ethernet/marvell/skge.c: fix error return code
  2012-10-05 22:40 [PATCH 16/20 V2] drivers/net/ethernet/renesas/sh_eth.c: fix error return code Peter Senna Tschudin
  2012-10-05 22:40 ` [PATCH 17/20 V2] drivers/net/ethernet/sun/niu.c: " Peter Senna Tschudin
  2012-10-05 22:40 ` [PATCH 18/20 V2] drivers/net/ethernet/sun/sungem.c: " Peter Senna Tschudin
@ 2012-10-05 22:40 ` Peter Senna Tschudin
  2012-10-07 18:39   ` David Miller
  2012-10-05 22:40 ` [PATCH 20/20 V2] drivers/net/ethernet/marvell/sky2.c: " Peter Senna Tschudin
  2012-10-07 18:39 ` [PATCH 16/20 V2] drivers/net/ethernet/renesas/sh_eth.c: " David Miller
  4 siblings, 1 reply; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 22:40 UTC (permalink / raw)
  To: mlindner
  Cc: shemminger, netdev, linux-kernel, kernel-janitors,
	Peter Senna Tschudin

From: Peter Senna Tschudin <peter.senna@gmail.com>

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>

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---
Change from V1:
        Updated commit message. See:
        http://www.kernelhub.org/?p=2&msg=139319

 drivers/net/ethernet/marvell/skge.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index 5a30bf8..91836b5 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -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))

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 20/20 V2] drivers/net/ethernet/marvell/sky2.c: fix error return code
  2012-10-05 22:40 [PATCH 16/20 V2] drivers/net/ethernet/renesas/sh_eth.c: fix error return code Peter Senna Tschudin
                   ` (2 preceding siblings ...)
  2012-10-05 22:40 ` [PATCH 19/20 V2] drivers/net/ethernet/marvell/skge.c: " Peter Senna Tschudin
@ 2012-10-05 22:40 ` Peter Senna Tschudin
  2012-10-07 18:39   ` David Miller
  2012-10-07 18:39 ` [PATCH 16/20 V2] drivers/net/ethernet/renesas/sh_eth.c: " David Miller
  4 siblings, 1 reply; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 22:40 UTC (permalink / raw)
  To: mlindner
  Cc: shemminger, netdev, linux-kernel, kernel-janitors,
	Peter Senna Tschudin

From: Peter Senna Tschudin <peter.senna@gmail.com>

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>

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---
Change from V1:
        Updated commit message. See:
        http://www.kernelhub.org/?p=2&msg=139319

 drivers/net/ethernet/marvell/sky2.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index 2b0748d..78946fe 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -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);

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 16/20 V2] drivers/net/ethernet/renesas/sh_eth.c: fix error return code
  2012-10-05 22:40 [PATCH 16/20 V2] drivers/net/ethernet/renesas/sh_eth.c: fix error return code Peter Senna Tschudin
                   ` (3 preceding siblings ...)
  2012-10-05 22:40 ` [PATCH 20/20 V2] drivers/net/ethernet/marvell/sky2.c: " Peter Senna Tschudin
@ 2012-10-07 18:39 ` David Miller
  4 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2012-10-07 18:39 UTC (permalink / raw)
  To: peter.senna
  Cc: yoshihiro.shimoda.uh, nobuhiro.iwamatsu.yj, netdev, linux-kernel,
	kernel-janitors


Applied.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 17/20 V2] drivers/net/ethernet/sun/niu.c: fix error return code
  2012-10-05 22:40 ` [PATCH 17/20 V2] drivers/net/ethernet/sun/niu.c: " Peter Senna Tschudin
@ 2012-10-07 18:39   ` David Miller
  0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2012-10-07 18:39 UTC (permalink / raw)
  To: peter.senna
  Cc: mcarlson, eric.dumazet, mchan, shuah.khan, netdev, linux-kernel,
	kernel-janitors


Applied.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 18/20 V2] drivers/net/ethernet/sun/sungem.c: fix error return code
  2012-10-05 22:40 ` [PATCH 18/20 V2] drivers/net/ethernet/sun/sungem.c: " Peter Senna Tschudin
@ 2012-10-07 18:39   ` David Miller
  0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2012-10-07 18:39 UTC (permalink / raw)
  To: peter.senna
  Cc: jdmason, gerard.lledo, dhowells, joe, netdev, linux-kernel,
	kernel-janitors


Applied.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 19/20 V2] drivers/net/ethernet/marvell/skge.c: fix error return code
  2012-10-05 22:40 ` [PATCH 19/20 V2] drivers/net/ethernet/marvell/skge.c: " Peter Senna Tschudin
@ 2012-10-07 18:39   ` David Miller
  0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2012-10-07 18:39 UTC (permalink / raw)
  To: peter.senna; +Cc: mlindner, shemminger, netdev, linux-kernel, kernel-janitors


Applied.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 20/20 V2] drivers/net/ethernet/marvell/sky2.c: fix error return code
  2012-10-05 22:40 ` [PATCH 20/20 V2] drivers/net/ethernet/marvell/sky2.c: " Peter Senna Tschudin
@ 2012-10-07 18:39   ` David Miller
  0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2012-10-07 18:39 UTC (permalink / raw)
  To: peter.senna; +Cc: mlindner, shemminger, netdev, linux-kernel, kernel-janitors


Applied.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-10-07 18:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-05 22:40 [PATCH 16/20 V2] drivers/net/ethernet/renesas/sh_eth.c: fix error return code Peter Senna Tschudin
2012-10-05 22:40 ` [PATCH 17/20 V2] drivers/net/ethernet/sun/niu.c: " Peter Senna Tschudin
2012-10-07 18:39   ` David Miller
2012-10-05 22:40 ` [PATCH 18/20 V2] drivers/net/ethernet/sun/sungem.c: " Peter Senna Tschudin
2012-10-07 18:39   ` David Miller
2012-10-05 22:40 ` [PATCH 19/20 V2] drivers/net/ethernet/marvell/skge.c: " Peter Senna Tschudin
2012-10-07 18:39   ` David Miller
2012-10-05 22:40 ` [PATCH 20/20 V2] drivers/net/ethernet/marvell/sky2.c: " Peter Senna Tschudin
2012-10-07 18:39   ` David Miller
2012-10-07 18:39 ` [PATCH 16/20 V2] drivers/net/ethernet/renesas/sh_eth.c: " David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).