2012-08-19 08:44:44

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 0/14] fix error return code

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>
@ok exists@
identifier f,ret,i;
expression e;
constant c;
@@

f(...) {
<+...
(
return -c@i;
|
ret = -c@i;
... when != ret = e
return ret;
|
if (ret < 0) { ... return ret; }
)
...+> }

@r exists@
identifier ret,l,ok.f;
expression e1,e2,e3;
statement S;
position p1,p2,p3;
@@

f(...) {
... when any
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
when != &ret
(
if (<+... ret = e3 ...+>) S
|
if (<+... &ret ...+>) S
|
if@p2(...)
{
... when != ret = e2
when forall
return@p3 ret;
}
)
... when any
}

@bad exists@
position r.p1,r.p2;
statement S1,S2;
identifier r.ret;
expression e1;
@@

(
if@p1 (\(ret < 0\|ret != 0\)) S1
|
ret@p1 = 0
)
... when any
ret = e1
... when any
if@p2(...) S2

@bad2@
position r.p1,r.p2;
identifier r.ret;
expression e1;
statement S2;
@@

ret@p1 = 0
... when != if (...) { ... ret = e1 ... return ret; }
when any
if@p2(...) S2


@script:python depends on !bad && !bad2@
p1 << r.p1;
p2 << r.p2;
p3 << r.p3;
@@

cocci.print_main("",p1)
cocci.print_secs("",p2)
cocci.print_secs("",p3)
// </smpl>


2012-08-19 08:44:53

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 5/14] drivers/power/ab8500_charger.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
drivers/power/ab8500_charger.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index d4f0c98..c2ef947 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -2614,6 +2614,7 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
create_singlethread_workqueue("ab8500_charger_wq");
if (di->charger_wq == NULL) {
dev_err(di->dev, "failed to create work queue\n");
+ ret = -ENOMEM;
goto free_device_info;
}

2012-08-19 08:45:04

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 2/14] drivers/power/ab8500_btemp.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
drivers/power/ab8500_btemp.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c
index bba3cca..2b76943 100644
--- a/drivers/power/ab8500_btemp.c
+++ b/drivers/power/ab8500_btemp.c
@@ -1014,6 +1014,7 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev)
create_singlethread_workqueue("ab8500_btemp_wq");
if (di->btemp_wq == NULL) {
dev_err(di->dev, "failed to create work queue\n");
+ ret = -ENOMEM;
goto free_device_info;
}

2012-08-19 08:44:59

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 3/14] drivers/power/ab8500_fg.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
drivers/power/ab8500_fg.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c
index bf02225..11633e3 100644
--- a/drivers/power/ab8500_fg.c
+++ b/drivers/power/ab8500_fg.c
@@ -2506,6 +2506,7 @@ static int __devinit ab8500_fg_probe(struct platform_device *pdev)
di->fg_wq = create_singlethread_workqueue("ab8500_fg_wq");
if (di->fg_wq == NULL) {
dev_err(di->dev, "failed to create work queue\n");
+ ret = -ENOMEM;
goto free_device_info;
}

2012-08-19 08:44:56

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 4/14] drivers/power/bq27x00_battery.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
drivers/power/bq27x00_battery.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index 181ddec..5860d4d 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -814,7 +814,8 @@ static int bq27x00_battery_probe(struct i2c_client *client,
di->bat.name = name;
di->bus.read = &bq27x00_read_i2c;

- if (bq27x00_powersupply_init(di))
+ retval = bq27x00_powersupply_init(di);
+ if (retval)
goto batt_failed_3;

i2c_set_clientdata(client, di);

2012-08-19 08:45:54

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 14/14] drivers/spi/spi-s3c24xx.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
Perhaps -EINVAL is not the right value in this case.

drivers/spi/spi-s3c24xx.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/spi/spi-s3c24xx.c b/drivers/spi/spi-s3c24xx.c
index 8ee7d79..a2a080b 100644
--- a/drivers/spi/spi-s3c24xx.c
+++ b/drivers/spi/spi-s3c24xx.c
@@ -611,6 +611,7 @@ static int __devinit s3c24xx_spi_probe(struct platform_device *pdev)
if (!pdata->set_cs) {
if (pdata->pin_cs < 0) {
dev_err(&pdev->dev, "No chipselect pin\n");
+ err = -EINVAL;
goto err_register;
}

2012-08-19 08:46:38

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 13/14] drivers/mtd/ubi/build.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
drivers/mtd/ubi/build.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 7b6b5f9..afe9075 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -1159,8 +1159,10 @@ static int __init ubi_init(void)
ubi_wl_entry_slab = kmem_cache_create("ubi_wl_entry_slab",
sizeof(struct ubi_wl_entry),
0, 0, NULL);
- if (!ubi_wl_entry_slab)
+ if (!ubi_wl_entry_slab) {
+ err = -ENOMEM;
goto out_dev_unreg;
+ }

err = ubi_debugfs_init();
if (err)

2012-08-19 08:46:58

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 9/14] drivers/spi/spi-omap-100k.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
Actually, omap1_spi100k_reset currently always returns 0, so the test is
never true. Perhaps this should be taken into account in some other way.

drivers/spi/spi-omap-100k.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c
index 9bd1c92..b581107 100644
--- a/drivers/spi/spi-omap-100k.c
+++ b/drivers/spi/spi-omap-100k.c
@@ -542,7 +542,8 @@ static int __devinit omap1_spi100k_probe(struct platform_device *pdev)
goto err2;
}

- if (omap1_spi100k_reset(spi100k) < 0)
+ status = omap1_spi100k_reset(spi100k);
+ if (status < 0)
goto err3;

status = spi_register_master(master);

2012-08-19 08:47:21

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 10/14] drivers/spi/spi-ep93xx.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
drivers/spi/spi-ep93xx.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index f97f1d2..9e7fdfd 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -1105,6 +1105,7 @@ static int __devinit ep93xx_spi_probe(struct platform_device *pdev)
espi->wq = create_singlethread_workqueue("ep93xx_spid");
if (!espi->wq) {
dev_err(&pdev->dev, "unable to create workqueue\n");
+ error = -ENOMEM;
goto fail_free_dma;
}
INIT_WORK(&espi->msg_work, ep93xx_spi_work);

2012-08-19 08:47:58

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 11/14] drivers/spi/spi-orion.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
Actually, orion_spi_reset currently always returns 0, so the test is
never true. Perhaps this should be taken into account in some other way.

drivers/spi/spi-orion.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index b17c09c..cc12803 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -435,7 +435,8 @@ static int __init orion_spi_probe(struct platform_device *pdev)
}
spi->base = ioremap(r->start, SZ_1K);

- if (orion_spi_reset(spi) < 0)
+ status = orion_spi_reset(spi);
+ if (status < 0)
goto out_rel_mem;

master->dev.of_node = pdev->dev.of_node;

2012-08-19 08:48:29

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 7/14] drivers/mtd/maps/rbtx4939-flash.c: delete unneeded test

From: Julia Lawall <[email protected]>

Err has only been initialized to 0 at this, so it is not possible that this
test can be true.

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: Julia Lawall <[email protected]>

---
drivers/mtd/maps/rbtx4939-flash.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/mtd/maps/rbtx4939-flash.c b/drivers/mtd/maps/rbtx4939-flash.c
index 6f52e1f..49c3fe7 100644
--- a/drivers/mtd/maps/rbtx4939-flash.c
+++ b/drivers/mtd/maps/rbtx4939-flash.c
@@ -100,8 +100,6 @@ static int rbtx4939_flash_probe(struct platform_device *dev)
goto err_out;
}
info->mtd->owner = THIS_MODULE;
- if (err)
- goto err_out;
err = mtd_device_parse_register(info->mtd, NULL, NULL, pdata->parts,
pdata->nr_parts);

2012-08-19 08:48:23

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 8/14] drivers/video/sunxvr2500.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
drivers/video/sunxvr2500.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/video/sunxvr2500.c b/drivers/video/sunxvr2500.c
index 5848436..7fbcba8 100644
--- a/drivers/video/sunxvr2500.c
+++ b/drivers/video/sunxvr2500.c
@@ -181,8 +181,10 @@ static int __devinit s3d_pci_register(struct pci_dev *pdev,
sp->fb_size = info->fix.line_length * sp->height;

sp->fb_base = ioremap(sp->fb_base_phys, sp->fb_size);
- if (!sp->fb_base)
+ if (!sp->fb_base) {
+ err = -ENOMEM;
goto err_release_pci;
+ }

err = s3d_set_fbinfo(sp);
if (err)

2012-08-19 08:48:21

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 12/14] drivers/spi/spi-coldfire-qspi.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
drivers/spi/spi-coldfire-qspi.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/spi/spi-coldfire-qspi.c b/drivers/spi/spi-coldfire-qspi.c
index b2d4b9e..7889796 100644
--- a/drivers/spi/spi-coldfire-qspi.c
+++ b/drivers/spi/spi-coldfire-qspi.c
@@ -462,6 +462,7 @@ static int __devinit mcfqspi_probe(struct platform_device *pdev)
pdata = pdev->dev.platform_data;
if (!pdata) {
dev_dbg(&pdev->dev, "platform data is missing\n");
+ status = -EINVAL;
goto fail4;
}
master->bus_num = pdata->bus_num;

2012-08-19 08:49:15

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 6/14] drivers/power/wm97xx_battery.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
drivers/power/wm97xx_battery.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/wm97xx_battery.c
index d2d4c08..0ba331a 100644
--- a/drivers/power/wm97xx_battery.c
+++ b/drivers/power/wm97xx_battery.c
@@ -212,8 +212,10 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
props++; /* POWER_SUPPLY_PROP_VOLTAGE_MIN */

prop = kzalloc(props * sizeof(*prop), GFP_KERNEL);
- if (!prop)
+ if (!prop) {
+ ret = -ENOMEM;
goto err3;
+ }

prop[i++] = POWER_SUPPLY_PROP_PRESENT;
if (pdata->charge_gpio >= 0)

2012-08-19 08:49:20

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 1/14] drivers/rpmsg/virtio_rpmsg_bus.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
drivers/rpmsg/virtio_rpmsg_bus.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index 590cfaf..c5e66d9 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -959,8 +959,10 @@ static int rpmsg_probe(struct virtio_device *vdev)
bufs_va = dma_alloc_coherent(vdev->dev.parent->parent,
RPMSG_TOTAL_BUF_SPACE,
&vrp->bufs_dma, GFP_KERNEL);
- if (!bufs_va)
+ if (!bufs_va) {
+ err = -ENOMEM;
goto vqs_del;
+ }

dev_dbg(&vdev->dev, "buffers: va %p, dma 0x%llx\n", bufs_va,
(unsigned long long)vrp->bufs_dma);

2012-08-22 09:38:41

by Kukjin Kim

[permalink] [raw]
Subject: RE: [PATCH 14/14] drivers/spi/spi-s3c24xx.c: fix error return code

Julia Lawall wrote:
>
> From: Julia Lawall <[email protected]>
>
> Initialize return variable before exiting on an error path.
>
> 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: Julia Lawall <[email protected]>
>
Acked-by: Kukjin Kim <[email protected]>

(Cc'ed Mark Brown who is handling spi for a moment)

> ---
> Perhaps -EINVAL is not the right value in this case.
>
Well, if (pin_cs < 0) is true, it is really invalid value. So I think, it
makes sense :-)

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer,
SW Solution Development Team, Samsung Electronics Co., Ltd.

> drivers/spi/spi-s3c24xx.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/spi/spi-s3c24xx.c b/drivers/spi/spi-s3c24xx.c
> index 8ee7d79..a2a080b 100644
> --- a/drivers/spi/spi-s3c24xx.c
> +++ b/drivers/spi/spi-s3c24xx.c
> @@ -611,6 +611,7 @@ static int __devinit s3c24xx_spi_probe(struct
> platform_device *pdev)
> if (!pdata->set_cs) {
> if (pdata->pin_cs < 0) {
> dev_err(&pdev->dev, "No chipselect pin\n");
> + err = -EINVAL;
> goto err_register;
> }
>

2012-08-22 11:40:21

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 14/14] drivers/spi/spi-s3c24xx.c: fix error return code

On Wed, Aug 22, 2012 at 06:38:36PM +0900, Kukjin Kim wrote:
> Julia Lawall wrote:

> > Signed-off-by: Julia Lawall <[email protected]>

> Acked-by: Kukjin Kim <[email protected]>

> (Cc'ed Mark Brown who is handling spi for a moment)

Please resend the patch to me so I can apply this.


Attachments:
(No filename) (293.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2012-08-22 11:42:53

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 14/14] drivers/spi/spi-s3c24xx.c: fix error return code

From: Julia Lawall <[email protected]>

Initialize return variable before exiting on an error path.

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: Julia Lawall <[email protected]>

---
Perhaps -EINVAL is not the right value in this case.

drivers/spi/spi-s3c24xx.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/spi/spi-s3c24xx.c b/drivers/spi/spi-s3c24xx.c
index 8ee7d79..a2a080b 100644
--- a/drivers/spi/spi-s3c24xx.c
+++ b/drivers/spi/spi-s3c24xx.c
@@ -611,6 +611,7 @@ static int __devinit s3c24xx_spi_probe(struct platform_device *pdev)
if (!pdata->set_cs) {
if (pdata->pin_cs < 0) {
dev_err(&pdev->dev, "No chipselect pin\n");
+ err = -EINVAL;
goto err_register;
}

2012-08-22 16:12:34

by Hartley Sweeten

[permalink] [raw]
Subject: RE: [PATCH 10/14] drivers/spi/spi-ep93xx.c: fix error return code

On Sunday, August 19, 2012 1:44 AM, Julia Lawall wrote:
> From: Julia Lawall <[email protected]>
>
> Initialize return variable before exiting on an error path.

<snip>

> Signed-off-by: Julia Lawall <[email protected]>
>
> ---
> drivers/spi/spi-ep93xx.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
> index f97f1d2..9e7fdfd 100644
> --- a/drivers/spi/spi-ep93xx.c
> +++ b/drivers/spi/spi-ep93xx.c
> @@ -1105,6 +1105,7 @@ static int __devinit ep93xx_spi_probe(struct platform_device *pdev)
> espi->wq = create_singlethread_workqueue("ep93xx_spid");
> if (!espi->wq) {
> dev_err(&pdev->dev, "unable to create workqueue\n");
> + error = -ENOMEM;
> goto fail_free_dma;
> }
> INIT_WORK(&espi->msg_work, ep93xx_spi_work);

Looks ok to me... Thanks!

Reviewed-by: H Hartley Sweeten <[email protected]>

2012-08-22 17:00:29

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 14/14] drivers/spi/spi-s3c24xx.c: fix error return code

On Wed, Aug 22, 2012 at 01:42:47PM +0200, Julia Lawall wrote:
> From: Julia Lawall <[email protected]>
>
> Initialize return variable before exiting on an error path.

Applied, thanks.


Attachments:
(No filename) (189.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2012-08-23 01:53:28

by Anton Vorontsov

[permalink] [raw]
Subject: Re: [PATCH 2/14] drivers/power/ab8500_btemp.c: fix error return code

On Sun, Aug 19, 2012 at 10:44:22AM +0200, Julia Lawall wrote:
> From: Julia Lawall <[email protected]>
[...]
> Signed-off-by: Julia Lawall <[email protected]>

2,3,4,5,6 applied, thanks!

> ---
> drivers/power/ab8500_btemp.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c
> index bba3cca..2b76943 100644
> --- a/drivers/power/ab8500_btemp.c
> +++ b/drivers/power/ab8500_btemp.c
> @@ -1014,6 +1014,7 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev)
> create_singlethread_workqueue("ab8500_btemp_wq");
> if (di->btemp_wq == NULL) {
> dev_err(di->dev, "failed to create work queue\n");
> + ret = -ENOMEM;
> goto free_device_info;
> }
>

Subject: Re: [PATCH 8/14] drivers/video/sunxvr2500.c: fix error return code

On 08/19/2012 08:44 AM, Julia Lawall wrote:
> From: Julia Lawall <[email protected]>
>
> Initialize return variable before exiting on an error path.
>
> 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: Julia Lawall <[email protected]>

Applied.


Thanks,

Florian Tobias Schandinat

>
> ---
> drivers/video/sunxvr2500.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/video/sunxvr2500.c b/drivers/video/sunxvr2500.c
> index 5848436..7fbcba8 100644
> --- a/drivers/video/sunxvr2500.c
> +++ b/drivers/video/sunxvr2500.c
> @@ -181,8 +181,10 @@ static int __devinit s3d_pci_register(struct pci_dev *pdev,
> sp->fb_size = info->fix.line_length * sp->height;
>
> sp->fb_base = ioremap(sp->fb_base_phys, sp->fb_size);
> - if (!sp->fb_base)
> + if (!sp->fb_base) {
> + err = -ENOMEM;
> goto err_release_pci;
> + }
>
> err = s3d_set_fbinfo(sp);
> if (err)
>
>

2012-08-25 11:04:59

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [PATCH 7/14] drivers/mtd/maps/rbtx4939-flash.c: delete unneeded test

On Sun, 2012-08-19 at 10:44 +0200, Julia Lawall wrote:
> From: Julia Lawall <[email protected]>
>
> Err has only been initialized to 0 at this, so it is not possible that this
> test can be true.
>
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)

Pushed to l2-mt.git, thanks!

--
Best Regards,
Artem Bityutskiy


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2012-08-25 11:10:23

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [PATCH 13/14] drivers/mtd/ubi/build.c: fix error return code

On Sun, 2012-08-19 at 10:44 +0200, Julia Lawall wrote:
> From: Julia Lawall <[email protected]>
>
> Initialize return variable before exiting on an error path.

Pushed to linux-ubi.git, thanks!

--
Best Regards,
Artem Bityutskiy


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part