netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 11/20 V2] drivers/net/irda/sh_sir.c: fix error return code
@ 2012-10-05 22:10 Peter Senna Tschudin
  2012-10-05 22:10 ` [PATCH 12/20 V2] drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c: " Peter Senna Tschudin
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 22:10 UTC (permalink / raw)
  To: samuel
  Cc: irda-users, netdev, linux-kernel, kernel-janitors,
	Peter Senna Tschudin

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

The function sh_sir_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_mem_*:. 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/irda/sh_sir.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/irda/sh_sir.c b/drivers/net/irda/sh_sir.c
index 7951094..624ac19 100644
--- a/drivers/net/irda/sh_sir.c
+++ b/drivers/net/irda/sh_sir.c
@@ -741,6 +741,7 @@ static int __devinit sh_sir_probe(struct platform_device *pdev)
 	self->clk = clk_get(&pdev->dev, clk_name);
 	if (IS_ERR(self->clk)) {
 		dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name);
+		err = -ENODEV;
 		goto err_mem_3;
 	}
 
@@ -760,8 +761,8 @@ static int __devinit sh_sir_probe(struct platform_device *pdev)
 		goto err_mem_4;
 
 	platform_set_drvdata(pdev, ndev);
-
-	if (request_irq(irq, sh_sir_irq, IRQF_DISABLED, "sh_sir", self)) {
+	err = request_irq(irq, sh_sir_irq, IRQF_DISABLED, "sh_sir", self);
+	if (err) {
 		dev_warn(&pdev->dev, "Unable to attach sh_sir interrupt\n");
 		goto err_mem_4;
 	}

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

* [PATCH 12/20 V2] drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c: fix error return code
  2012-10-05 22:10 [PATCH 11/20 V2] drivers/net/irda/sh_sir.c: fix error return code Peter Senna Tschudin
@ 2012-10-05 22:10 ` Peter Senna Tschudin
  2012-10-07 18:38   ` David Miller
  2012-10-05 22:10 ` [PATCH 13/20 V2] drivers/net/ethernet/amd/amd8111e.c: " Peter Senna Tschudin
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 22:10 UTC (permalink / raw)
  To: jitendra.kalsaria
  Cc: sony.chacko, linux-driver, netdev, linux-kernel, kernel-janitors,
	Peter Senna Tschudin

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

The function qlcnic_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_free_netdev:. 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/qlogic/qlcnic/qlcnic_main.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 473ce13..24ad17e 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -1601,7 +1601,8 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	adapter->netdev  = netdev;
 	adapter->pdev    = pdev;
 
-	if (qlcnic_alloc_adapter_resources(adapter))
+	err = qlcnic_alloc_adapter_resources(adapter);
+	if (err)
 		goto err_out_free_netdev;
 
 	adapter->dev_rst_time = jiffies;

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

* [PATCH 13/20 V2] drivers/net/ethernet/amd/amd8111e.c: fix error return code
  2012-10-05 22:10 [PATCH 11/20 V2] drivers/net/irda/sh_sir.c: fix error return code Peter Senna Tschudin
  2012-10-05 22:10 ` [PATCH 12/20 V2] drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c: " Peter Senna Tschudin
@ 2012-10-05 22:10 ` Peter Senna Tschudin
  2012-10-07 18:39   ` David Miller
  2012-10-05 22:10 ` [PATCH 14/20 V2] drivers/net/ethernet/amd/au1000_eth.c: " Peter Senna Tschudin
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 22:10 UTC (permalink / raw)
  To: davem
  Cc: joe, dhowells, rick.jones2, netdev, netdev, linux-kernel,
	kernel-janitors, Peter Senna Tschudin

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

The function amd8111e_probe_one() 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_free_reg:. 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/amd/amd8111e.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/amd/amd8111e.c b/drivers/net/ethernet/amd/amd8111e.c
index 64d0d9c..3491d43 100644
--- a/drivers/net/ethernet/amd/amd8111e.c
+++ b/drivers/net/ethernet/amd/amd8111e.c
@@ -1845,6 +1845,7 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
 	if((pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM))==0){
 		printk(KERN_ERR "amd8111e: No Power Management capability, "
 		       "exiting.\n");
+		err = -ENODEV;
 		goto err_free_reg;
 	}
 
@@ -1852,6 +1853,7 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
 	if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) < 0) {
 		printk(KERN_ERR "amd8111e: DMA not supported,"
 			"exiting.\n");
+		err = -ENODEV;
 		goto err_free_reg;
 	}
 

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

* [PATCH 14/20 V2] drivers/net/ethernet/amd/au1000_eth.c: fix error return code
  2012-10-05 22:10 [PATCH 11/20 V2] drivers/net/irda/sh_sir.c: fix error return code Peter Senna Tschudin
  2012-10-05 22:10 ` [PATCH 12/20 V2] drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c: " Peter Senna Tschudin
  2012-10-05 22:10 ` [PATCH 13/20 V2] drivers/net/ethernet/amd/amd8111e.c: " Peter Senna Tschudin
@ 2012-10-05 22:10 ` Peter Senna Tschudin
  2012-10-07 18:39   ` David Miller
  2012-10-05 22:10 ` [PATCH 15/20 V2] drivers/net/ethernet/natsemi/xtsonic.c: " Peter Senna Tschudin
       [not found] ` <1349475053-11464-1-git-send-email-peter.senna-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  4 siblings, 1 reply; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 22:10 UTC (permalink / raw)
  To: davem
  Cc: danny.kukawka, mcuos.com, joe, florian, netdev, linux-kernel,
	kernel-janitors, Peter Senna Tschudin

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

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>

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

 drivers/net/ethernet/amd/au1000_eth.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index 397596b..f195acf 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)
 	snprintf(aup->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
 		pdev->name, aup->mac_id);
 	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;
+	}
 
 	for (i = 0; i < PHY_MAX_ADDR; ++i)
 		aup->mii_bus->irq[i] = PHY_POLL;
@@ -1190,7 +1192,8 @@ static int __devinit au1000_probe(struct platform_device *pdev)
 		goto err_mdiobus_reg;
 	}
 
-	if (au1000_mii_probe(dev) != 0)
+	err = au1000_mii_probe(dev);
+	if (err != 0)
 		goto err_out;
 
 	pDBfree = NULL;
@@ -1205,6 +1208,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)
 	}
 	aup->pDBfree = pDBfree;
 
+	err = -ENODEV;
 	for (i = 0; i < NUM_RX_DMA; i++) {
 		pDB = au1000_GetFreeDB(aup);
 		if (!pDB)
@@ -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_db_inuse[i] = pDB;
 	}
+
+	err = -ENODEV;
 	for (i = 0; i < NUM_TX_DMA; i++) {
 		pDB = au1000_GetFreeDB(aup);
 		if (!pDB)

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

* [PATCH 15/20 V2] drivers/net/ethernet/natsemi/xtsonic.c: fix error return code
  2012-10-05 22:10 [PATCH 11/20 V2] drivers/net/irda/sh_sir.c: fix error return code Peter Senna Tschudin
                   ` (2 preceding siblings ...)
  2012-10-05 22:10 ` [PATCH 14/20 V2] drivers/net/ethernet/amd/au1000_eth.c: " Peter Senna Tschudin
@ 2012-10-05 22:10 ` Peter Senna Tschudin
  2012-10-07 18:39   ` David Miller
       [not found] ` <1349475053-11464-1-git-send-email-peter.senna-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  4 siblings, 1 reply; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 22:10 UTC (permalink / raw)
  To: davem
  Cc: mcuos.com, axel.lin, netdev, linux-kernel, kernel-janitors,
	Peter Senna Tschudin

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

The function sonic_probe1() 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:. 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/natsemi/xtsonic.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/natsemi/xtsonic.c b/drivers/net/ethernet/natsemi/xtsonic.c
index e01c0a0..7dfe883 100644
--- a/drivers/net/ethernet/natsemi/xtsonic.c
+++ b/drivers/net/ethernet/natsemi/xtsonic.c
@@ -205,6 +205,7 @@ static int __init sonic_probe1(struct net_device *dev)
 	if (lp->descriptors == NULL) {
 		printk(KERN_ERR "%s: couldn't alloc DMA memory for "
 				" descriptors.\n", dev_name(lp->device));
+		err = -ENOMEM;
 		goto out;
 	}
 

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

* Re: [PATCH 11/20 V2] drivers/net/irda/sh_sir.c: fix error return code
       [not found] ` <1349475053-11464-1-git-send-email-peter.senna-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-10-07 18:38   ` David Miller
  0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2012-10-07 18:38 UTC (permalink / raw)
  To: peter.senna-Re5JQEeQqe8AvxtiuMwx3w
  Cc: irda-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	samuel-jcdQHdrhKHMdnm+yROfE0A,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA


Applied.

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev

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

* Re: [PATCH 12/20 V2] drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c: fix error return code
  2012-10-05 22:10 ` [PATCH 12/20 V2] drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c: " Peter Senna Tschudin
@ 2012-10-07 18:38   ` David Miller
  0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2012-10-07 18:38 UTC (permalink / raw)
  To: peter.senna
  Cc: jitendra.kalsaria, sony.chacko, linux-driver, netdev,
	linux-kernel, kernel-janitors


Applied.

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

* Re: [PATCH 13/20 V2] drivers/net/ethernet/amd/amd8111e.c: fix error return code
  2012-10-05 22:10 ` [PATCH 13/20 V2] drivers/net/ethernet/amd/amd8111e.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: joe, dhowells, rick.jones2, netdev, netdev, linux-kernel,
	kernel-janitors


Applied.

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

* Re: [PATCH 14/20 V2] drivers/net/ethernet/amd/au1000_eth.c: fix error return code
  2012-10-05 22:10 ` [PATCH 14/20 V2] drivers/net/ethernet/amd/au1000_eth.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: danny.kukawka, mcuos.com, joe, florian, netdev, linux-kernel,
	kernel-janitors


Applied.

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

* Re: [PATCH 15/20 V2] drivers/net/ethernet/natsemi/xtsonic.c: fix error return code
  2012-10-05 22:10 ` [PATCH 15/20 V2] drivers/net/ethernet/natsemi/xtsonic.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: mcuos.com, axel.lin, 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:10 [PATCH 11/20 V2] drivers/net/irda/sh_sir.c: fix error return code Peter Senna Tschudin
2012-10-05 22:10 ` [PATCH 12/20 V2] drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c: " Peter Senna Tschudin
2012-10-07 18:38   ` David Miller
2012-10-05 22:10 ` [PATCH 13/20 V2] drivers/net/ethernet/amd/amd8111e.c: " Peter Senna Tschudin
2012-10-07 18:39   ` David Miller
2012-10-05 22:10 ` [PATCH 14/20 V2] drivers/net/ethernet/amd/au1000_eth.c: " Peter Senna Tschudin
2012-10-07 18:39   ` David Miller
2012-10-05 22:10 ` [PATCH 15/20 V2] drivers/net/ethernet/natsemi/xtsonic.c: " Peter Senna Tschudin
2012-10-07 18:39   ` David Miller
     [not found] ` <1349475053-11464-1-git-send-email-peter.senna-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-07 18:38   ` [PATCH 11/20 V2] drivers/net/irda/sh_sir.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).