* [PATCH 0/7] fix error return code
@ 2014-11-20 17:33 Julia Lawall
2014-11-20 17:33 ` [PATCH 2/7] gdrom: " Julia Lawall
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Julia Lawall @ 2014-11-20 17:33 UTC (permalink / raw)
To: linux-arm-kernel
The complate semantic patch that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@ok exists@
identifier f,ret,i;
expression e;
constant c;
@@
// identify a function that returns a negative return value at least once.
f(...) {
... when any
(
return -c@i;
|
ret = -c@i;
... when != ret = e
return ret;
|
if (ret < 0) { ... return ret; }
)
... when any
}
@r exists@
identifier ret,ok.f,fn;
expression e1,e2,e3,e4,e5,e6,x;
statement S,S1;
position p1,p2,p3;
@@
// identify a case where the return variable is set to a non-negative value
// and then returned in error-handling code
f(...) {
... when any
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != \(ret = e1\|ret++\|ret--\|ret+á\|ret-á\)
when != &ret
when any
(
if (<+... ret = e5 ...+>) S1
|
if (<+... &ret ...+>) S1
|
if@p2(<+...x = fn(...)...+>)
{
... when != ret = e6
when forall
return@p3 ret;
}
|
break;
|
x = fn(...)
... when != \(ret = e4\|ret++\|ret--\|ret+ä\|ret-ä\)
when != &ret
(
if (<+... ret = e3 ...+>) S
|
if (<+... &ret ...+>) S
|
if@p2(<+...\(x != 0\|x < 0\|x = NULL\|IS_ERR(x)\)...+>)
{
... when != ret = e2
when forall
return@p3 ret;
}
)
)
... when any
}
@printer depends on r@
position p;
identifier ok.f,pr;
constant char [] c;
@@
f(...) { <...pr@p(...,c,...)...> }
@bad0 exists@
identifier r.ret,ok.f,g != {ERR_PTR,IS_ERR};
position p != printer.p;
@@
f(...) { ... when any
g@p(...,ret,...)
... when any
}
@bad depends on !bad0 exists@
position r.p1,r.p2;
statement S1,S2;
identifier r.ret;
expression e1;
@@
// ignore the above if there is some path where the variable is set to
// something else
(
if@p1 (\(ret < 0\|ret != 0\)) S1
|
ret@p1 = 0
)
... when any
\(ret = e1\|ret++\|ret--\|ret+á\|ret-á\|&ret\)
... when any
if@p2(...) S2
@bad1 depends on !bad0 && !bad exists@
position r.p2;
statement S2;
identifier r.ret;
expression e1;
constant c;
@@
ret = -c
... when != \(ret = e1\|ret++\|ret--\|ret+á\|ret-á\)
when != &ret
when any
if@p2(...) S2
@bad2 depends on !bad0 && !bad && !bad1 exists@
position r.p1,r.p2;
identifier r.ret;
expression e1;
statement S2;
constant c;
@@
// likewise ignore it if there has been an intervening return
ret@p1 = 0
... when != if (...) { ... ret = e1 ... return ret; }
when != if (...) { ... return -c; }
when any
if@p2(...) S2
@script:python depends on !bad0 && !bad && !bad1 && !bad2@
p1 << r.p1;
p2 << r.p2;
p3 << r.p3;
@@
cocci.print_main("",p1)
cocci.print_secs("",p2)
cocci.print_secs("",p3)
// </smpl>
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/7] gdrom: fix error return code
2014-11-20 17:33 [PATCH 0/7] fix error return code Julia Lawall
@ 2014-11-20 17:33 ` Julia Lawall
2014-11-20 17:33 ` [PATCH 1/7] umem: " Julia Lawall
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2014-11-20 17:33 UTC (permalink / raw)
To: linux-kernel; +Cc: kernel-janitors
From: Julia Lawall <Julia.Lawall@lip6.fr>
Return a negative error code on failure.
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\|ret != 0\))
{ ... return ret; }
|
ret = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
The patches in this series are independent of each other.
drivers/cdrom/gdrom.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index 584bc31..46ecd95 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -807,16 +807,20 @@ static int probe_gdrom(struct platform_device *devptr)
if (err)
goto probe_fail_cmdirq_register;
gd.gdrom_rq = blk_init_queue(gdrom_request, &gdrom_lock);
- if (!gd.gdrom_rq)
+ if (!gd.gdrom_rq) {
+ err = -ENOMEM;
goto probe_fail_requestq;
+ }
err = probe_gdrom_setupqueue();
if (err)
goto probe_fail_toc;
gd.toc = kzalloc(sizeof(struct gdromtoc), GFP_KERNEL);
- if (!gd.toc)
+ if (!gd.toc) {
+ err = -ENOMEM;
goto probe_fail_toc;
+ }
add_disk(gd.disk);
return 0;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 1/7] umem: fix error return code
2014-11-20 17:33 [PATCH 0/7] fix error return code Julia Lawall
2014-11-20 17:33 ` [PATCH 2/7] gdrom: " Julia Lawall
@ 2014-11-20 17:33 ` Julia Lawall
2014-11-20 17:33 ` [PATCH 3/7] dwc3: dwc3-keystone: " Julia Lawall
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2014-11-20 17:33 UTC (permalink / raw)
To: linux-kernel; +Cc: kernel-janitors
From: Julia Lawall <Julia.Lawall@lip6.fr>
Return a negative error code on failure.
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\|ret != 0\))
{ ... return ret; }
|
ret = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
The patches in this series are independent of each other.
drivers/block/umem.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/block/umem.c b/drivers/block/umem.c
index 4cf81b5..371e819 100644
--- a/drivers/block/umem.c
+++ b/drivers/block/umem.c
@@ -881,6 +881,7 @@ static int mm_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
if (card->mm_pages[0].desc = NULL ||
card->mm_pages[1].desc = NULL) {
dev_printk(KERN_ERR, &card->dev->dev, "alloc failed\n");
+ ret = -ENOMEM;
goto failed_alloc;
}
reset_page(&card->mm_pages[0]);
@@ -891,8 +892,10 @@ static int mm_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
card->biotail = &card->bio;
card->queue = blk_alloc_queue(GFP_KERNEL);
- if (!card->queue)
+ if (!card->queue) {
+ ret = -ENOMEM;
goto failed_alloc;
+ }
blk_queue_make_request(card->queue, mm_make_request);
card->queue->queue_lock = &card->lock;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/7] dwc3: dwc3-keystone: fix error return code
2014-11-20 17:33 [PATCH 0/7] fix error return code Julia Lawall
2014-11-20 17:33 ` [PATCH 2/7] gdrom: " Julia Lawall
2014-11-20 17:33 ` [PATCH 1/7] umem: " Julia Lawall
@ 2014-11-20 17:33 ` Julia Lawall
2014-11-20 17:33 ` [PATCH 4/7] serial: icom: " Julia Lawall
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2014-11-20 17:33 UTC (permalink / raw)
To: Felipe Balbi
Cc: kernel-janitors, Greg Kroah-Hartman, linux-usb, linux-omap, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6.fr>
Return a negative error code on failure.
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\|ret != 0\))
{ ... return ret; }
|
ret = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
The patches in this series are independent of each other.
drivers/usb/dwc3/dwc3-keystone.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/dwc3/dwc3-keystone.c b/drivers/usb/dwc3/dwc3-keystone.c
index dd8d2df..fe3b933 100644
--- a/drivers/usb/dwc3/dwc3-keystone.c
+++ b/drivers/usb/dwc3/dwc3-keystone.c
@@ -123,6 +123,7 @@ static int kdwc3_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0);
if (irq < 0) {
dev_err(&pdev->dev, "missing irq\n");
+ error = irq;
goto err_irq;
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/7] serial: icom: fix error return code
2014-11-20 17:33 [PATCH 0/7] fix error return code Julia Lawall
` (2 preceding siblings ...)
2014-11-20 17:33 ` [PATCH 3/7] dwc3: dwc3-keystone: " Julia Lawall
@ 2014-11-20 17:33 ` Julia Lawall
2014-11-20 17:34 ` [PATCH 5/7] rsxx: " Julia Lawall
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2014-11-20 17:33 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: kernel-janitors, Jiri Slaby, linux-serial, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6.fr>
Return a negative error code on failure.
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\|ret != 0\))
{ ... return ret; }
|
ret = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
The patches in this series are independent of each other.
drivers/tty/serial/icom.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c
index d4620fe..45fc323 100644
--- a/drivers/tty/serial/icom.c
+++ b/drivers/tty/serial/icom.c
@@ -1550,8 +1550,10 @@ static int icom_probe(struct pci_dev *dev,
icom_adapter->base_addr = pci_ioremap_bar(dev, 0);
- if (!icom_adapter->base_addr)
+ if (!icom_adapter->base_addr) {
+ retval = -ENOMEM;
goto probe_exit1;
+ }
/* save off irq and request irq line */
if ( (retval = request_irq(dev->irq, icom_interrupt,
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/7] rsxx: fix error return code
2014-11-20 17:33 [PATCH 0/7] fix error return code Julia Lawall
` (3 preceding siblings ...)
2014-11-20 17:33 ` [PATCH 4/7] serial: icom: " Julia Lawall
@ 2014-11-20 17:34 ` Julia Lawall
2014-11-20 17:34 ` [PATCH 6/7] host: ehci-w90x900: " Julia Lawall
2014-11-20 17:34 ` [PATCH 7/7] parport_sunbpp: " Julia Lawall
6 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2014-11-20 17:34 UTC (permalink / raw)
To: Joshua Morris; +Cc: kernel-janitors, Philip Kelleher, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6.fr>
Return a negative error code on failure.
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\|ret != 0\))
{ ... return ret; }
|
ret = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
The patches in this series are independent of each other.
drivers/block/rsxx/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c
index d8b2488..3801721 100644
--- a/drivers/block/rsxx/core.c
+++ b/drivers/block/rsxx/core.c
@@ -893,6 +893,7 @@ static int rsxx_pci_probe(struct pci_dev *dev,
card->event_wq = create_singlethread_workqueue(DRIVER_NAME"_event");
if (!card->event_wq) {
dev_err(CARD_TO_DEV(card), "Failed card event setup.\n");
+ st = -ENOMEM;
goto failed_event_handler;
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/7] host: ehci-w90x900: fix error return code
2014-11-20 17:33 [PATCH 0/7] fix error return code Julia Lawall
` (4 preceding siblings ...)
2014-11-20 17:34 ` [PATCH 5/7] rsxx: " Julia Lawall
@ 2014-11-20 17:34 ` Julia Lawall
2014-11-20 17:34 ` [PATCH 7/7] parport_sunbpp: " Julia Lawall
6 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2014-11-20 17:34 UTC (permalink / raw)
To: linux-arm-kernel
From: Julia Lawall <Julia.Lawall@lip6.fr>
Return a negative error code on failure.
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\|ret != 0\))
{ ... return ret; }
|
ret = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
The patches in this series are independent of each other.
drivers/usb/host/ehci-w90x900.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/ehci-w90x900.c b/drivers/usb/host/ehci-w90x900.c
index 93d9cd6..e42a29e 100644
--- a/drivers/usb/host/ehci-w90x900.c
+++ b/drivers/usb/host/ehci-w90x900.c
@@ -75,8 +75,10 @@ static int usb_w90x900_probe(const struct hc_driver *driver,
__raw_writel(val, ehci->regs+PHY1_CTR);
irq = platform_get_irq(pdev, 0);
- if (irq < 0)
+ if (irq < 0) {
+ retval = irq;
goto err2;
+ }
retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (retval != 0)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 7/7] parport_sunbpp: fix error return code
2014-11-20 17:33 [PATCH 0/7] fix error return code Julia Lawall
` (5 preceding siblings ...)
2014-11-20 17:34 ` [PATCH 6/7] host: ehci-w90x900: " Julia Lawall
@ 2014-11-20 17:34 ` Julia Lawall
6 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2014-11-20 17:34 UTC (permalink / raw)
To: linux-kernel; +Cc: kernel-janitors
From: Julia Lawall <Julia.Lawall@lip6.fr>
Return a negative error code on failure.
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\|ret != 0\))
{ ... return ret; }
|
ret = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>
The patch also removes a newly unnecessary initialization of err, replaces
spaces by a tab, and pulls an assignment out of a conditional test
expression.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
The patches in this series are independent of each other.
drivers/parport/parport_sunbpp.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c
index 01cf1c1..14f4cb8 100644
--- a/drivers/parport/parport_sunbpp.c
+++ b/drivers/parport/parport_sunbpp.c
@@ -269,7 +269,7 @@ static int bpp_probe(struct platform_device *op)
{
struct parport_operations *ops;
struct bpp_regs __iomem *regs;
- int irq, dma, err = 0, size;
+ int irq, dma, err, size;
unsigned char value_tcr;
void __iomem *base;
struct parport *p;
@@ -286,12 +286,17 @@ static int bpp_probe(struct platform_device *op)
ops = kmemdup(&parport_sunbpp_ops, sizeof(struct parport_operations),
GFP_KERNEL);
- if (!ops)
+ if (!ops) {
+ err = -ENOMEM;
goto out_unmap;
+ }
dprintk(("register_port\n"));
- if (!(p = parport_register_port((unsigned long)base, irq, dma, ops)))
+ p = parport_register_port((unsigned long)base, irq, dma, ops);
+ if (!p) {
+ err = -ENOMEM;
goto out_free_ops;
+ }
p->size = size;
p->dev = &op->dev;
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-11-20 17:34 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-20 17:33 [PATCH 0/7] fix error return code Julia Lawall
2014-11-20 17:33 ` [PATCH 2/7] gdrom: " Julia Lawall
2014-11-20 17:33 ` [PATCH 1/7] umem: " Julia Lawall
2014-11-20 17:33 ` [PATCH 3/7] dwc3: dwc3-keystone: " Julia Lawall
2014-11-20 17:33 ` [PATCH 4/7] serial: icom: " Julia Lawall
2014-11-20 17:34 ` [PATCH 5/7] rsxx: " Julia Lawall
2014-11-20 17:34 ` [PATCH 6/7] host: ehci-w90x900: " Julia Lawall
2014-11-20 17:34 ` [PATCH 7/7] parport_sunbpp: " Julia Lawall
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).