* [PATCH 6/20 V2] drivers/net/irda/irtty-sir.c: fix error return code
2012-10-05 21:33 [PATCH 10/20 V2] drivers/net/irda/sh_irda.c: fix error return code Peter Senna Tschudin
@ 2012-10-05 21:33 ` Peter Senna Tschudin
2012-10-07 18:38 ` David Miller
2012-10-05 21:33 ` [PATCH 7/20 V2] drivers/net/irda/mcs7780.c: " Peter Senna Tschudin
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 21:33 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 irtty_open() 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_put:. 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\x139319
drivers/net/irda/irtty-sir.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
index 30087ca..6e4d4b6 100644
--- a/drivers/net/irda/irtty-sir.c
+++ b/drivers/net/irda/irtty-sir.c
@@ -459,8 +459,10 @@ static int irtty_open(struct tty_struct *tty)
/* allocate private device info block */
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
- if (!priv)
+ if (!priv) {
+ ret = -ENOMEM;
goto out_put;
+ }
priv->magic = IRTTY_MAGIC;
priv->tty = tty;
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 7/20 V2] drivers/net/irda/mcs7780.c: fix error return code
2012-10-05 21:33 [PATCH 10/20 V2] drivers/net/irda/sh_irda.c: fix error return code Peter Senna Tschudin
2012-10-05 21:33 ` [PATCH 6/20 V2] drivers/net/irda/irtty-sir.c: " Peter Senna Tschudin
@ 2012-10-05 21:33 ` Peter Senna Tschudin
2012-10-07 18:38 ` David Miller
2012-10-05 21:33 ` [PATCH 8/20 V2] drivers/net/irda/pxaficp_ir.c: " Peter Senna Tschudin
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 21:33 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 mcs_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 error2:. 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.
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\x139319
drivers/net/irda/mcs7780.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index 1a00b59..f07c340 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -920,8 +920,10 @@ static int mcs_probe(struct usb_interface *intf,
ndev->netdev_ops = &mcs_netdev_ops;
- if (!intf->cur_altsetting)
+ if (!intf->cur_altsetting) {
+ ret = -ENOMEM;
goto error2;
+ }
ret = mcs_find_endpoints(mcs, intf->cur_altsetting->endpoint,
intf->cur_altsetting->desc.bNumEndpoints);
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 8/20 V2] drivers/net/irda/pxaficp_ir.c: fix error return code
2012-10-05 21:33 [PATCH 10/20 V2] drivers/net/irda/sh_irda.c: fix error return code Peter Senna Tschudin
2012-10-05 21:33 ` [PATCH 6/20 V2] drivers/net/irda/irtty-sir.c: " Peter Senna Tschudin
2012-10-05 21:33 ` [PATCH 7/20 V2] drivers/net/irda/mcs7780.c: " Peter Senna Tschudin
@ 2012-10-05 21:33 ` Peter Senna Tschudin
2012-10-07 18:38 ` David Miller
2012-10-05 21:33 ` [PATCH 9/20 V2] drivers/net/irda/sa1100_ir.c: " Peter Senna Tschudin
2012-10-07 18:38 ` [PATCH 10/20 V2] drivers/net/irda/sh_irda.c: " David Miller
4 siblings, 1 reply; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 21:33 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 pxa_irda_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_mem_3:. 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\x139319
drivers/net/irda/pxaficp_ir.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index 002a442..858de05 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -846,8 +846,10 @@ static int pxa_irda_probe(struct platform_device *pdev)
goto err_mem_2;
dev = alloc_irdadev(sizeof(struct pxa_irda));
- if (!dev)
+ if (!dev) {
+ err = -ENOMEM;
goto err_mem_3;
+ }
SET_NETDEV_DEV(dev, &pdev->dev);
si = netdev_priv(dev);
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 9/20 V2] drivers/net/irda/sa1100_ir.c: fix error return code
2012-10-05 21:33 [PATCH 10/20 V2] drivers/net/irda/sh_irda.c: fix error return code Peter Senna Tschudin
` (2 preceding siblings ...)
2012-10-05 21:33 ` [PATCH 8/20 V2] drivers/net/irda/pxaficp_ir.c: " Peter Senna Tschudin
@ 2012-10-05 21:33 ` Peter Senna Tschudin
2012-10-07 18:38 ` David Miller
2012-10-07 18:38 ` [PATCH 10/20 V2] drivers/net/irda/sh_irda.c: " David Miller
4 siblings, 1 reply; 10+ messages in thread
From: Peter Senna Tschudin @ 2012-10-05 21:33 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 sa1100_irda_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_mem_4:. 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\x139319
drivers/net/irda/sa1100_ir.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index e250675..42fde9e 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -940,8 +940,10 @@ static int sa1100_irda_probe(struct platform_device *pdev)
goto err_mem_3;
dev = alloc_irdadev(sizeof(struct sa1100_irda));
- if (!dev)
+ if (!dev) {
+ err = -ENOMEM;
goto err_mem_4;
+ }
SET_NETDEV_DEV(dev, &pdev->dev);
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 10/20 V2] drivers/net/irda/sh_irda.c: fix error return code
2012-10-05 21:33 [PATCH 10/20 V2] drivers/net/irda/sh_irda.c: fix error return code Peter Senna Tschudin
` (3 preceding siblings ...)
2012-10-05 21:33 ` [PATCH 9/20 V2] drivers/net/irda/sa1100_ir.c: " Peter Senna Tschudin
@ 2012-10-07 18:38 ` David Miller
4 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2012-10-07 18:38 UTC (permalink / raw)
To: peter.senna; +Cc: samuel, irda-users, netdev, linux-kernel, kernel-janitors
Applied.
^ permalink raw reply [flat|nested] 10+ messages in thread