netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/5] drivers/net/ethernet/freescale/fs_enet: fix error return code
       [not found] <1344949115-13266-1-git-send-email-Julia.Lawall@lip6.fr>
@ 2012-08-14 12:58 ` Julia Lawall
  2012-08-15  0:01   ` David Miller
  2012-08-14 12:58 ` [PATCH 4/5] drivers/net/ethernet/mellanox/mlx4/mcg.c: " Julia Lawall
  1 sibling, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2012-08-14 12:58 UTC (permalink / raw)
  To: Pantelis Antoniou
  Cc: kernel-janitors, Vitaly Bordug, linuxppc-dev, netdev,
	linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Convert a 0 error return code to a negative one, as returned elsewhere in the
function.

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

// <smpl>
@@
identifier ret;
expression e,e1,e2,e3,e4,x;
@@

(
if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
|
ret = 0
)
... when != ret = e1
*x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
... when != x = e2
    when != ret = e3
*if (x == NULL || ...)
{
  ... when != ret = e4
*  return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c |    4 +++-
 drivers/net/ethernet/freescale/fs_enet/mii-fec.c     |    8 ++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c b/drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c
index 0f2d1a7..1514533 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c
@@ -174,8 +174,10 @@ static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev)
 
 	new_bus->phy_mask = ~0;
 	new_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
-	if (!new_bus->irq)
+	if (!new_bus->irq) {
+		ret = -ENOMEM;
 		goto out_unmap_regs;
+	}
 
 	new_bus->parent = &ofdev->dev;
 	dev_set_drvdata(&ofdev->dev, new_bus);
diff --git a/drivers/net/ethernet/freescale/fs_enet/mii-fec.c b/drivers/net/ethernet/freescale/fs_enet/mii-fec.c
index 55bb867..cdf702a 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mii-fec.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mii-fec.c
@@ -137,8 +137,10 @@ static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev)
 	snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", res.start);
 
 	fec->fecp = ioremap(res.start, resource_size(&res));
-	if (!fec->fecp)
+	if (!fec->fecp) {
+		ret = -ENOMEM;
 		goto out_fec;
+	}
 
 	if (get_bus_freq) {
 		clock = get_bus_freq(ofdev->dev.of_node);
@@ -172,8 +174,10 @@ static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev)
 
 	new_bus->phy_mask = ~0;
 	new_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
-	if (!new_bus->irq)
+	if (!new_bus->irq) {
+		ret = -ENOMEM;
 		goto out_unmap_regs;
+	}
 
 	new_bus->parent = &ofdev->dev;
 	dev_set_drvdata(&ofdev->dev, new_bus);

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

* [PATCH 4/5] drivers/net/ethernet/mellanox/mlx4/mcg.c: fix error return code
       [not found] <1344949115-13266-1-git-send-email-Julia.Lawall@lip6.fr>
  2012-08-14 12:58 ` [PATCH 3/5] drivers/net/ethernet/freescale/fs_enet: fix error return code Julia Lawall
@ 2012-08-14 12:58 ` Julia Lawall
  2012-08-15  0:01   ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2012-08-14 12:58 UTC (permalink / raw)
  To: netdev; +Cc: kernel-janitors, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Convert a 0 error return code to a negative one, as returned elsewhere in the
function.

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

// <smpl>
@@
identifier ret;
expression e,e1,e2,e3,e4,x;
@@

(
if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
|
ret = 0
)
... when != ret = e1
*x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
... when != x = e2
    when != ret = e3
*if (x == NULL || ...)
{
  ... when != ret = e4
*  return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/net/ethernet/mellanox/mlx4/mcg.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c
index 4ec3835..a018ea2 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mcg.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c
@@ -432,8 +432,10 @@ static int add_promisc_qp(struct mlx4_dev *dev, u8 port,
 			if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qpn) {
 				/* Entry already exists, add to duplicates */
 				dqp = kmalloc(sizeof *dqp, GFP_KERNEL);
-				if (!dqp)
+				if (!dqp) {
+					err = -ENOMEM;
 					goto out_mailbox;
+				}
 				dqp->qpn = qpn;
 				list_add_tail(&dqp->list, &entry->duplicates);
 				found = true;

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

* Re: [PATCH 3/5] drivers/net/ethernet/freescale/fs_enet: fix error return code
  2012-08-14 12:58 ` [PATCH 3/5] drivers/net/ethernet/freescale/fs_enet: fix error return code Julia Lawall
@ 2012-08-15  0:01   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2012-08-15  0:01 UTC (permalink / raw)
  To: Julia.Lawall
  Cc: pantelis.antoniou, kernel-janitors, vbordug, linuxppc-dev, netdev,
	linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Tue, 14 Aug 2012 14:58:33 +0200

> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> Convert a 0 error return code to a negative one, as returned elsewhere in the
> function.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
 ...
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Applied.

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

* Re: [PATCH 4/5] drivers/net/ethernet/mellanox/mlx4/mcg.c: fix error return code
  2012-08-14 12:58 ` [PATCH 4/5] drivers/net/ethernet/mellanox/mlx4/mcg.c: " Julia Lawall
@ 2012-08-15  0:01   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2012-08-15  0:01 UTC (permalink / raw)
  To: Julia.Lawall; +Cc: netdev, kernel-janitors, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Tue, 14 Aug 2012 14:58:34 +0200

> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> Convert a 0 error return code to a negative one, as returned elsewhere in the
> function.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
 ...
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Applied.

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

end of thread, other threads:[~2012-08-15  0:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1344949115-13266-1-git-send-email-Julia.Lawall@lip6.fr>
2012-08-14 12:58 ` [PATCH 3/5] drivers/net/ethernet/freescale/fs_enet: fix error return code Julia Lawall
2012-08-15  0:01   ` David Miller
2012-08-14 12:58 ` [PATCH 4/5] drivers/net/ethernet/mellanox/mlx4/mcg.c: " Julia Lawall
2012-08-15  0:01   ` 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).