* [PATCH 0/3] fix error return code
@ 2012-08-17 7:46 Julia Lawall
2012-08-17 7:46 ` [PATCH 1/3] drivers/net/wimax/i2400m/fw.c: " Julia Lawall
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Julia Lawall @ 2012-08-17 7:46 UTC (permalink / raw)
To: netdev; +Cc: kernel-janitors, linux-kernel
These patches fix cases where the return code appears to be unintentially
nonnegative.
The complete semantic match that finds the problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
identifier ret,l;
expression e1,e2,e3;
statement S;
@@
if (ret < 0)
{ ... return ret; }
... when != ret = e1
when forall
(
goto l;
|
return ...;
|
if (<+... ret = e3 ...+>) S
|
*if(...)
{
... when != ret = e2
* return ret;
}
)
// </smpl>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] drivers/net/wimax/i2400m/fw.c: fix error return code
2012-08-17 7:46 [PATCH 0/3] fix error return code Julia Lawall
@ 2012-08-17 7:46 ` Julia Lawall
2012-08-17 7:46 ` [PATCH 2/3] drivers/net/wan/dscc4.c: " Julia Lawall
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2012-08-17 7:46 UTC (permalink / raw)
To: Inaky Perez-Gonzalez
Cc: kernel-janitors, linux-wimax, wimax, netdev, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6.fr>
Convert a nonnegative 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 e1,e2;
@@
if (ret < 0)
{ ... return ret; }
... when != ret = e1
when forall
*if(...)
{
... when != ret = e2
* return ret;
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/net/wimax/i2400m/fw.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wimax/i2400m/fw.c b/drivers/net/wimax/i2400m/fw.c
index 283237f..def12b3 100644
--- a/drivers/net/wimax/i2400m/fw.c
+++ b/drivers/net/wimax/i2400m/fw.c
@@ -326,8 +326,10 @@ int i2400m_barker_db_init(const char *_options)
unsigned barker;
options_orig = kstrdup(_options, GFP_KERNEL);
- if (options_orig == NULL)
+ if (options_orig == NULL) {
+ result = -ENOMEM;
goto error_parse;
+ }
options = options_orig;
while ((token = strsep(&options, ",")) != NULL) {
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] drivers/net/wan/dscc4.c: fix error return code
2012-08-17 7:46 [PATCH 0/3] fix error return code Julia Lawall
2012-08-17 7:46 ` [PATCH 1/3] drivers/net/wimax/i2400m/fw.c: " Julia Lawall
@ 2012-08-17 7:46 ` Julia Lawall
2012-08-17 7:46 ` [PATCH 3/3] drivers/net/irda: " Julia Lawall
2012-08-20 9:33 ` [PATCH 0/3] " David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2012-08-17 7:46 UTC (permalink / raw)
To: Francois Romieu; +Cc: kernel-janitors, netdev, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6.fr>
Move up the initialization of rc so that failure of pci_alloc_consistent
returns -ENOMEM as well.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
identifier ret;
expression e1,e2;
@@
if (ret < 0)
{ ... return ret; }
... when != ret = e1
when forall
*if(...)
{
... when != ret = e2
* return ret;
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/net/wan/dscc4.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 9eb6479..ef36caf 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -774,14 +774,15 @@ static int __devinit dscc4_init_one(struct pci_dev *pdev,
}
/* Global interrupt queue */
writel((u32)(((IRQ_RING_SIZE >> 5) - 1) << 20), ioaddr + IQLENR1);
+
+ rc = -ENOMEM;
+
priv->iqcfg = (__le32 *) pci_alloc_consistent(pdev,
IRQ_RING_SIZE*sizeof(__le32), &priv->iqcfg_dma);
if (!priv->iqcfg)
goto err_free_irq_5;
writel(priv->iqcfg_dma, ioaddr + IQCFG);
- rc = -ENOMEM;
-
/*
* SCC 0-3 private rx/tx irq structures
* IQRX/TXi needs to be set soon. Learned it the hard way...
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] drivers/net/irda: fix error return code
2012-08-17 7:46 [PATCH 0/3] fix error return code Julia Lawall
2012-08-17 7:46 ` [PATCH 1/3] drivers/net/wimax/i2400m/fw.c: " Julia Lawall
2012-08-17 7:46 ` [PATCH 2/3] drivers/net/wan/dscc4.c: " Julia Lawall
@ 2012-08-17 7:46 ` Julia Lawall
2012-08-20 9:33 ` [PATCH 0/3] " David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2012-08-17 7:46 UTC (permalink / raw)
To: Samuel Ortiz; +Cc: kernel-janitors, netdev, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6.fr>
Convert a nonnegative 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 e1,e2;
@@
if (ret < 0)
{ ... return ret; }
... when != ret = e1
when forall
*if(...)
{
... when != ret = e2
* return ret;
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/net/irda/ks959-sir.c | 1 +
drivers/net/irda/ksdazzle-sir.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/drivers/net/irda/ks959-sir.c b/drivers/net/irda/ks959-sir.c
index 824e2a9..5f3aeac 100644
--- a/drivers/net/irda/ks959-sir.c
+++ b/drivers/net/irda/ks959-sir.c
@@ -542,6 +542,7 @@ static int ks959_net_open(struct net_device *netdev)
sprintf(hwname, "usb#%d", kingsun->usbdev->devnum);
kingsun->irlap = irlap_open(netdev, &kingsun->qos, hwname);
if (!kingsun->irlap) {
+ err = -ENOMEM;
dev_err(&kingsun->usbdev->dev, "irlap_open failed\n");
goto free_mem;
}
diff --git a/drivers/net/irda/ksdazzle-sir.c b/drivers/net/irda/ksdazzle-sir.c
index 5a278ab..2d4b6a1 100644
--- a/drivers/net/irda/ksdazzle-sir.c
+++ b/drivers/net/irda/ksdazzle-sir.c
@@ -436,6 +436,7 @@ static int ksdazzle_net_open(struct net_device *netdev)
sprintf(hwname, "usb#%d", kingsun->usbdev->devnum);
kingsun->irlap = irlap_open(netdev, &kingsun->qos, hwname);
if (!kingsun->irlap) {
+ err = -ENOMEM;
dev_err(&kingsun->usbdev->dev, "irlap_open failed\n");
goto free_mem;
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] fix error return code
2012-08-17 7:46 [PATCH 0/3] fix error return code Julia Lawall
` (2 preceding siblings ...)
2012-08-17 7:46 ` [PATCH 3/3] drivers/net/irda: " Julia Lawall
@ 2012-08-20 9:33 ` David Miller
3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2012-08-20 9:33 UTC (permalink / raw)
To: Julia.Lawall; +Cc: netdev, kernel-janitors, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Fri, 17 Aug 2012 09:46:55 +0200
> These patches fix cases where the return code appears to be unintentially
> nonnegative.
All applied, thanks Julia.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-08-20 9:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-17 7:46 [PATCH 0/3] fix error return code Julia Lawall
2012-08-17 7:46 ` [PATCH 1/3] drivers/net/wimax/i2400m/fw.c: " Julia Lawall
2012-08-17 7:46 ` [PATCH 2/3] drivers/net/wan/dscc4.c: " Julia Lawall
2012-08-17 7:46 ` [PATCH 3/3] drivers/net/irda: " Julia Lawall
2012-08-20 9:33 ` [PATCH 0/3] " 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).