kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/16] fix error return code
@ 2015-04-05 12:06 Julia Lawall
  2015-04-05 12:06 ` [PATCH 1/16] wan: lmc: " Julia Lawall
                   ` (15 more replies)
  0 siblings, 16 replies; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: devel
  Cc: linux-wireless, alsa-devel, linux-scsi, linux-rdma, netdev,
	kernel-janitors, linux-kernel, dri-devel, HPDD-discuss,
	linux-input, linux-arm-kernel, linux-media

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] 27+ messages in thread

* [PATCH 1/16] wan: lmc: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-07 19:26   ` David Miller
  2015-04-05 12:06 ` [PATCH 2/16] [media] si4713: " Julia Lawall
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: netdev; +Cc: kernel-janitors, linux-kernel

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>

---
 drivers/net/wan/lmc/lmc_main.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index bea0f31..317bc79 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -850,6 +850,7 @@ static int lmc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	dev = alloc_hdlcdev(sc);
 	if (!dev) {
 		printk(KERN_ERR "lmc:alloc_netdev for device failed\n");
+		err = -ENOMEM;
 		goto err_hdlcdev;
 	}
 


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

* [PATCH 2/16] [media] si4713: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
  2015-04-05 12:06 ` [PATCH 1/16] wan: lmc: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-05 12:06 ` [PATCH 4/16] [media] as102: " Julia Lawall
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: kernel-janitors, Mauro Carvalho Chehab, linux-media, linux-kernel

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>

---
 drivers/media/radio/si4713/si4713.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/radio/si4713/si4713.c b/drivers/media/radio/si4713/si4713.c
index c90004d..c4e1d6c 100644
--- a/drivers/media/radio/si4713/si4713.c
+++ b/drivers/media/radio/si4713/si4713.c
@@ -1615,8 +1615,10 @@ static int si4713_probe(struct i2c_client *client,
 		return 0;
 
 	si4713_pdev = platform_device_alloc("radio-si4713", -1);
-	if (!si4713_pdev)
+	if (!si4713_pdev) {
+		rval = -ENOMEM;
 		goto put_main_pdev;
+	}
 
 	si4713_pdev_pdata.subdev = client;
 	rval = platform_device_add_data(si4713_pdev, &si4713_pdev_pdata,


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

* [PATCH 4/16] [media] as102: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
  2015-04-05 12:06 ` [PATCH 1/16] wan: lmc: " Julia Lawall
  2015-04-05 12:06 ` [PATCH 2/16] [media] si4713: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-05 12:06 ` [PATCH 3/16] [media] radio: " Julia Lawall
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: kernel-janitors, linux-media, linux-kernel

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>

---
 drivers/media/usb/as102/as102_drv.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/as102/as102_drv.c b/drivers/media/usb/as102/as102_drv.c
index 8be1474..9dd7c7c 100644
--- a/drivers/media/usb/as102/as102_drv.c
+++ b/drivers/media/usb/as102/as102_drv.c
@@ -337,6 +337,7 @@ int as102_dvb_register(struct as102_dev_t *as102_dev)
 				       &as102_dev->bus_adap,
 				       as102_dev->elna_cfg);
 	if (!as102_dev->dvb_fe) {
+		ret = -ENODEV;
 		dev_err(dev, "%s: as102_attach() failed: %d",
 		    __func__, ret);
 		goto efereg;


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

* [PATCH 3/16] [media] radio: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
                   ` (2 preceding siblings ...)
  2015-04-05 12:06 ` [PATCH 4/16] [media] as102: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-05 12:06 ` [PATCH 5/16] ufs: " Julia Lawall
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: kernel-janitors, linux-media, linux-kernel

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>

---
 drivers/media/radio/radio-timb.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c
index e6b55ed..04baafe 100644
--- a/drivers/media/radio/radio-timb.c
+++ b/drivers/media/radio/radio-timb.c
@@ -138,8 +138,10 @@ static int timbradio_probe(struct platform_device *pdev)
 		i2c_get_adapter(pdata->i2c_adapter), pdata->tuner, NULL);
 	tr->sd_dsp = v4l2_i2c_new_subdev_board(&tr->v4l2_dev,
 		i2c_get_adapter(pdata->i2c_adapter), pdata->dsp, NULL);
-	if (tr->sd_tuner = NULL || tr->sd_dsp = NULL)
+	if (tr->sd_tuner = NULL || tr->sd_dsp = NULL) {
+		err = -ENODEV;
 		goto err_video_req;
+	}
 
 	tr->v4l2_dev.ctrl_handler = tr->sd_dsp->ctrl_handler;
 


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

* [PATCH 5/16] ufs: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
                   ` (3 preceding siblings ...)
  2015-04-05 12:06 ` [PATCH 3/16] [media] radio: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-05 12:06 ` [PATCH 6/16] HSI: cmt_speech: " Julia Lawall
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: Vinayak Holikatti
  Cc: kernel-janitors, James E.J. Bottomley, linux-scsi, linux-kernel

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>

This patch also changes the subsequent dev_err call to use err rather
than recomputing PTR_ERR(hba->devfreq).  The format of the error value
is changed from %ld to %d to reflect the type or err.

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

---
 drivers/scsi/ufs/ufshcd.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 2aa85e3..8b802d1 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -5506,8 +5506,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
 		hba->devfreq = devfreq_add_device(dev, &ufs_devfreq_profile,
 						   "simple_ondemand", NULL);
 		if (IS_ERR(hba->devfreq)) {
-			dev_err(hba->dev, "Unable to register with devfreq %ld\n",
-					PTR_ERR(hba->devfreq));
+			err = PTR_ERR(hba->devfreq);
+			dev_err(hba->dev, "Unable to register with devfreq %d\n",
+					err);
 			goto out_remove_scsi_host;
 		}
 		/* Suspend devfreq until the UFS device is detected */


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

* [PATCH 6/16] HSI: cmt_speech: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
                   ` (4 preceding siblings ...)
  2015-04-05 12:06 ` [PATCH 5/16] ufs: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-05 12:47   ` Sebastian Reichel
  2015-04-05 12:06 ` [PATCH 7/16] parport_sunbpp: " Julia Lawall
                   ` (9 subsequent siblings)
  15 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: kernel-janitors, linux-kernel

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>

---
 drivers/hsi/clients/cmt_speech.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hsi/clients/cmt_speech.c b/drivers/hsi/clients/cmt_speech.c
index e9560ef..4983529 100644
--- a/drivers/hsi/clients/cmt_speech.c
+++ b/drivers/hsi/clients/cmt_speech.c
@@ -1028,6 +1028,7 @@ static int cs_hsi_start(struct cs_hsi_iface **hi, struct hsi_client *cl,
 	}
 	hsi_if->master = ssip_slave_get_master(cl);
 	if (IS_ERR(hsi_if->master)) {
+		err = PTR_ERR(hsi_if->master);
 		dev_err(&cl->device, "Could not get HSI master client\n");
 		goto leave4;
 	}


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

* [PATCH 7/16] parport_sunbpp: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
                   ` (5 preceding siblings ...)
  2015-04-05 12:06 ` [PATCH 6/16] HSI: cmt_speech: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-05 12:06 ` [PATCH 8/16] cosa: " Julia Lawall
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors

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>

To satisfy checkpatch, this patch also changes leading spaces to a tab in
the first changed line, and extracts an assignment from an if condition.

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

---
 drivers/parport/parport_sunbpp.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c
index 01cf1c1..d7ad4b3 100644
--- a/drivers/parport/parport_sunbpp.c
+++ b/drivers/parport/parport_sunbpp.c
@@ -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] 27+ messages in thread

* [PATCH 8/16] cosa: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
                   ` (6 preceding siblings ...)
  2015-04-05 12:06 ` [PATCH 7/16] parport_sunbpp: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-07 19:26   ` David Miller
  2015-04-05 12:06 ` [PATCH 9/16] HID: logitech-hidpp: " Julia Lawall
                   ` (7 subsequent siblings)
  15 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: Jan "Yenya" Kasprzak; +Cc: kernel-janitors, netdev, linux-kernel

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>

---
 drivers/net/wan/cosa.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index 88d121d..bcfa01a 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -579,6 +579,7 @@ static int cosa_probe(int base, int irq, int dma)
 		/* Register the network interface */
 		if (!(chan->netdev = alloc_hdlcdev(chan))) {
 			pr_warn("%s: alloc_hdlcdev failed\n", chan->name);
+			err = -ENOMEM;
 			goto err_hdlcdev;
 		}
 		dev_to_hdlc(chan->netdev)->attach = cosa_net_attach;


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

* [PATCH 9/16] HID: logitech-hidpp: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
                   ` (7 preceding siblings ...)
  2015-04-05 12:06 ` [PATCH 8/16] cosa: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-05 14:38   ` Benjamin Tissoires
  2015-04-05 20:57   ` Jiri Kosina
  2015-04-05 12:06 ` [PATCH 10/16] zram: " Julia Lawall
                   ` (6 subsequent siblings)
  15 siblings, 2 replies; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: kernel-janitors, linux-input, linux-kernel

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>

---
 drivers/hid/hid-logitech-hidpp.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index e77658c..ce9819f 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -1210,6 +1210,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	connected = hidpp_is_connected(hidpp);
 	if (id->group != HID_GROUP_LOGITECH_DJ_DEVICE) {
 		if (!connected) {
+			ret = -ENODEV;
 			hid_err(hdev, "Device not connected");
 			hid_device_io_stop(hdev);
 			goto hid_parse_fail;


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

* [PATCH 10/16] zram: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
                   ` (8 preceding siblings ...)
  2015-04-05 12:06 ` [PATCH 9/16] HID: logitech-hidpp: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-05 12:06 ` [PATCH 11/16] drm/msm/dp: " Julia Lawall
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: Minchan Kim; +Cc: kernel-janitors, Nitin Gupta, linux-kernel

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>

---
 drivers/block/zram/zram_drv.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 759ee09..fe67ebb 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1188,6 +1188,7 @@ static int zram_add(int device_id)
 	if (!queue) {
 		pr_err("Error allocating disk queue for device %d\n",
 			device_id);
+		ret = -ENOMEM;
 		goto out_free_idr;
 	}
 
@@ -1198,6 +1199,7 @@ static int zram_add(int device_id)
 	if (!zram->disk) {
 		pr_warn("Error allocating disk structure for device %d\n",
 			device_id);
+		ret = -ENOMEM;
 		goto out_free_queue;
 	}
 


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

* [PATCH 11/16] drm/msm/dp: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
                   ` (9 preceding siblings ...)
  2015-04-05 12:06 ` [PATCH 10/16] zram: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-05 12:06 ` [PATCH 12/16] ib_srpt: " Julia Lawall
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: David Airlie; +Cc: kernel-janitors, dri-devel, linux-kernel

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>

---
 drivers/gpu/drm/msm/edp/edp_ctrl.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/edp/edp_ctrl.c b/drivers/gpu/drm/msm/edp/edp_ctrl.c
index 0ec5abd..29e52d7 100644
--- a/drivers/gpu/drm/msm/edp/edp_ctrl.c
+++ b/drivers/gpu/drm/msm/edp/edp_ctrl.c
@@ -1149,12 +1149,13 @@ int msm_edp_ctrl_init(struct msm_edp *edp)
 	ctrl->aux = msm_edp_aux_init(dev, ctrl->base, &ctrl->drm_aux);
 	if (!ctrl->aux || !ctrl->drm_aux) {
 		pr_err("%s:failed to init aux\n", __func__);
-		return ret;
+		return -ENOMEM;
 	}
 
 	ctrl->phy = msm_edp_phy_init(dev, ctrl->base);
 	if (!ctrl->phy) {
 		pr_err("%s:failed to init phy\n", __func__);
+		ret = -ENOMEM;
 		goto err_destory_aux;
 	}
 


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

* [PATCH 12/16] ib_srpt: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
                   ` (10 preceding siblings ...)
  2015-04-05 12:06 ` [PATCH 11/16] drm/msm/dp: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
       [not found]   ` <1428235596-4757-13-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
  2015-04-05 12:06 ` [PATCH 13/16] ALSA: au1x00: " Julia Lawall
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: Roland Dreier
  Cc: kernel-janitors, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel

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>

In the first case, the printk is changed to use the ret value, rather
than duplicating PTR_ERR(ch->thread).  This requires changing the format
from %ld to %d, to account for the type of ret.

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

---
 drivers/infiniband/ulp/srpt/ib_srpt.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 6e0a477..5ec98f5 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -2143,8 +2143,8 @@ retry:
 
 	ch->thread = kthread_run(srpt_compl_thread, ch, "ib_srpt_compl");
 	if (IS_ERR(ch->thread)) {
-		printk(KERN_ERR "failed to create kernel thread %ld\n",
-		       PTR_ERR(ch->thread));
+		ret = PTR_ERR(ch->thread);
+		printk(KERN_ERR "failed to create kernel thread %d\n", ret);
 		ch->thread = NULL;
 		goto err_destroy_qp;
 	}
@@ -2590,6 +2590,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
 		       " configured yet for initiator %s.\n", ch->sess_name);
 		rej->reason = __constant_cpu_to_be32(
 				SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED);
+		ret = -EINVAL;
 		goto destroy_ib;
 	}
 
@@ -2598,6 +2599,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
 		rej->reason = __constant_cpu_to_be32(
 				SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES);
 		pr_debug("Failed to create session\n");
+		ret = PTR_ERR(ch->sess);
 		goto deregister_session;
 	}
 	ch->sess->se_node_acl = &nacl->nacl;


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

* [PATCH 13/16] ALSA: au1x00: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
                   ` (11 preceding siblings ...)
  2015-04-05 12:06 ` [PATCH 12/16] ib_srpt: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-05 16:06   ` [alsa-devel] " Takashi Iwai
  2015-04-05 12:06 ` [PATCH 14/16] soc: ti: knav_qmss_queue: " Julia Lawall
                   ` (2 subsequent siblings)
  15 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: kernel-janitors, Takashi Iwai, alsa-devel, linux-kernel

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>

---
 sound/mips/au1x00.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c
index fbcaa54..1e30e84 100644
--- a/sound/mips/au1x00.c
+++ b/sound/mips/au1x00.c
@@ -633,19 +633,25 @@ static int au1000_ac97_probe(struct platform_device *pdev)
 
 	au1000->stream[PLAYBACK] = kmalloc(sizeof(struct audio_stream),
 					   GFP_KERNEL);
-	if (!au1000->stream[PLAYBACK])
+	if (!au1000->stream[PLAYBACK]) {
+		err = -ENOMEM;
 		goto out;
+	}
 	au1000->stream[PLAYBACK]->dma = -1;
 
 	au1000->stream[CAPTURE] = kmalloc(sizeof(struct audio_stream),
 					  GFP_KERNEL);
-	if (!au1000->stream[CAPTURE])
+	if (!au1000->stream[CAPTURE]) {
+		err = -ENOMEM;
 		goto out;
+	}
 	au1000->stream[CAPTURE]->dma = -1;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r)
+	if (!r) {
+		err = -ENODEV;
 		goto out;
+	}
 
 	err = -EBUSY;
 	au1000->ac97_res_port = request_mem_region(r->start, resource_size(r),


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

* [PATCH 14/16] soc: ti: knav_qmss_queue: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
                   ` (12 preceding siblings ...)
  2015-04-05 12:06 ` [PATCH 13/16] ALSA: au1x00: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-06  2:03   ` santosh.shilimkar
  2015-04-05 12:06 ` [PATCH 15/16] staging: lustre: lnet: lnet: " Julia Lawall
  2015-04-05 12:06 ` [PATCH 16/16] NFC: pn533: " Julia Lawall
  15 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: linux-arm-kernel

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>

---
 drivers/soc/ti/knav_qmss_queue.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index 6d8646d..822ead8 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -1768,6 +1768,7 @@ static int knav_queue_probe(struct platform_device *pdev)
 	regions =  of_get_child_by_name(node, "descriptor-regions");
 	if (!regions) {
 		dev_err(dev, "descriptor-regions not specified\n");
+		ret = -ENODEV;
 		goto err;
 	}
 	ret = knav_queue_setup_regions(kdev, regions);


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

* [PATCH 15/16] staging: lustre: lnet: lnet: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
                   ` (13 preceding siblings ...)
  2015-04-05 12:06 ` [PATCH 14/16] soc: ti: knav_qmss_queue: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-06  6:41   ` [HPDD-discuss] " Zhen, Liang
  2015-04-05 12:06 ` [PATCH 16/16] NFC: pn533: " Julia Lawall
  15 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: Oleg Drokin
  Cc: kernel-janitors, Andreas Dilger, Greg Kroah-Hartman, HPDD-discuss,
	devel, linux-kernel

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>

---
 drivers/staging/lustre/lnet/lnet/api-ni.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index faceb95..4a14e51 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -650,15 +650,19 @@ lnet_prepare(lnet_pid_t requested_pid)
 
 	recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME, LNET_FL_MAX_MES,
 					  sizeof(lnet_me_t));
-	if (recs = NULL)
+	if (recs = NULL) {
+		rc = -ENOMEM;
 		goto failed;
+	}
 
 	the_lnet.ln_me_containers = recs;
 
 	recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD, LNET_FL_MAX_MDS,
 					  sizeof(lnet_libmd_t));
-	if (recs = NULL)
+	if (recs = NULL) {
+		rc = -ENOMEM;
 		goto failed;
+	}
 
 	the_lnet.ln_md_containers = recs;
 


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

* [PATCH 16/16] NFC: pn533: fix error return code
  2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
                   ` (14 preceding siblings ...)
  2015-04-05 12:06 ` [PATCH 15/16] staging: lustre: lnet: lnet: " Julia Lawall
@ 2015-04-05 12:06 ` Julia Lawall
  2015-04-05 23:23   ` Samuel Ortiz
  15 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2015-04-05 12:06 UTC (permalink / raw)
  To: Lauro Ramos Venancio
  Cc: kernel-janitors, Aloisio Almeida Jr, Samuel Ortiz, linux-wireless,
	linux-kernel

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>

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

diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index d46a700..732e607 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -2554,8 +2554,10 @@ static int pn533_data_exchange_complete(struct pn533 *dev, void *_arg,
 	}
 
 	skb = pn533_build_response(dev);
-	if (!skb)
+	if (!skb) {
+		rc = -ENOMEM;
 		goto error;
+	}
 
 	arg->cb(arg->cb_context, skb, 0);
 	kfree(arg);


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

* Re: [PATCH 6/16] HSI: cmt_speech: fix error return code
  2015-04-05 12:06 ` [PATCH 6/16] HSI: cmt_speech: " Julia Lawall
@ 2015-04-05 12:47   ` Sebastian Reichel
  0 siblings, 0 replies; 27+ messages in thread
From: Sebastian Reichel @ 2015-04-05 12:47 UTC (permalink / raw)
  To: Julia Lawall; +Cc: kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]

Hi Julia,

On Sun, Apr 05, 2015 at 02:06:26PM +0200, Julia Lawall wrote:
> Return a negative error code on failure.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: [...]

Thanks, applied:

https://git.kernel.org/cgit/linux/kernel/git/sre/linux-hsi.git/commit/?h=for-next&id=265ef3ee9575e6d150f485d28dbe153a50d27f4c

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 9/16] HID: logitech-hidpp: fix error return code
  2015-04-05 12:06 ` [PATCH 9/16] HID: logitech-hidpp: " Julia Lawall
@ 2015-04-05 14:38   ` Benjamin Tissoires
  2015-04-05 20:57   ` Jiri Kosina
  1 sibling, 0 replies; 27+ messages in thread
From: Benjamin Tissoires @ 2015-04-05 14:38 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Jiri Kosina, kernel-janitors, linux-input,
	linux-kernel@vger.kernel.org

On Sun, Apr 5, 2015 at 8:06 AM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> 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>
>
> ---

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Thanks!
Benjamin

>  drivers/hid/hid-logitech-hidpp.c |    1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
> index e77658c..ce9819f 100644
> --- a/drivers/hid/hid-logitech-hidpp.c
> +++ b/drivers/hid/hid-logitech-hidpp.c
> @@ -1210,6 +1210,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
>         connected = hidpp_is_connected(hidpp);
>         if (id->group != HID_GROUP_LOGITECH_DJ_DEVICE) {
>                 if (!connected) {
> +                       ret = -ENODEV;
>                         hid_err(hdev, "Device not connected");
>                         hid_device_io_stop(hdev);
>                         goto hid_parse_fail;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" 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] 27+ messages in thread

* Re: [alsa-devel] [PATCH 13/16] ALSA: au1x00: fix error return code
  2015-04-05 12:06 ` [PATCH 13/16] ALSA: au1x00: " Julia Lawall
@ 2015-04-05 16:06   ` Takashi Iwai
  0 siblings, 0 replies; 27+ messages in thread
From: Takashi Iwai @ 2015-04-05 16:06 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Jaroslav Kysela, alsa-devel, kernel-janitors, linux-kernel

At Sun,  5 Apr 2015 14:06:33 +0200,
Julia Lawall wrote:
> 
> 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>

Applied, thanks.


Takashi

> 
> ---
>  sound/mips/au1x00.c |   12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c
> index fbcaa54..1e30e84 100644
> --- a/sound/mips/au1x00.c
> +++ b/sound/mips/au1x00.c
> @@ -633,19 +633,25 @@ static int au1000_ac97_probe(struct platform_device *pdev)
>  
>  	au1000->stream[PLAYBACK] = kmalloc(sizeof(struct audio_stream),
>  					   GFP_KERNEL);
> -	if (!au1000->stream[PLAYBACK])
> +	if (!au1000->stream[PLAYBACK]) {
> +		err = -ENOMEM;
>  		goto out;
> +	}
>  	au1000->stream[PLAYBACK]->dma = -1;
>  
>  	au1000->stream[CAPTURE] = kmalloc(sizeof(struct audio_stream),
>  					  GFP_KERNEL);
> -	if (!au1000->stream[CAPTURE])
> +	if (!au1000->stream[CAPTURE]) {
> +		err = -ENOMEM;
>  		goto out;
> +	}
>  	au1000->stream[CAPTURE]->dma = -1;
>  
>  	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!r)
> +	if (!r) {
> +		err = -ENODEV;
>  		goto out;
> +	}
>  
>  	err = -EBUSY;
>  	au1000->ac97_res_port = request_mem_region(r->start, resource_size(r),
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

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

* Re: [PATCH 12/16] ib_srpt: fix error return code
       [not found]   ` <1428235596-4757-13-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
@ 2015-04-05 16:27     ` Bart Van Assche
  0 siblings, 0 replies; 27+ messages in thread
From: Bart Van Assche @ 2015-04-05 16:27 UTC (permalink / raw)
  To: Julia Lawall, Roland Dreier
  Cc: kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Sean Hefty,
	Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On 04/05/15 14:06, Julia Lawall wrote:
> 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>
>
> In the first case, the printk is changed to use the ret value, rather
> than duplicating PTR_ERR(ch->thread).  This requires changing the format
> from %ld to %d, to account for the type of ret.
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>   drivers/infiniband/ulp/srpt/ib_srpt.c |    6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 6e0a477..5ec98f5 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -2143,8 +2143,8 @@ retry:
>
>   	ch->thread = kthread_run(srpt_compl_thread, ch, "ib_srpt_compl");
>   	if (IS_ERR(ch->thread)) {
> -		printk(KERN_ERR "failed to create kernel thread %ld\n",
> -		       PTR_ERR(ch->thread));
> +		ret = PTR_ERR(ch->thread);
> +		printk(KERN_ERR "failed to create kernel thread %d\n", ret);
>   		ch->thread = NULL;
>   		goto err_destroy_qp;
>   	}
> @@ -2590,6 +2590,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
>   		       " configured yet for initiator %s.\n", ch->sess_name);
>   		rej->reason = __constant_cpu_to_be32(
>   				SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED);
> +		ret = -EINVAL;
>   		goto destroy_ib;
>   	}
>
> @@ -2598,6 +2599,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
>   		rej->reason = __constant_cpu_to_be32(
>   				SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES);
>   		pr_debug("Failed to create session\n");
> +		ret = PTR_ERR(ch->sess);
>   		goto deregister_session;
>   	}
>   	ch->sess->se_node_acl = &nacl->nacl;

This is not the proper way to fix srpt_cm_req_recv(). The kthread_run() 
call must be moved from srpt_create_ch_ib() to after the session 
registration code in srpt_cm_req_recv(), and the session registration 
call + the kthread_run() call must be protected via a mutex against 
concurrent HCA hot-plug removal events (see also srpt_remove_one() and 
srpt_remove_sdev()).

Bart.

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

* Re: [PATCH 9/16] HID: logitech-hidpp: fix error return code
  2015-04-05 12:06 ` [PATCH 9/16] HID: logitech-hidpp: " Julia Lawall
  2015-04-05 14:38   ` Benjamin Tissoires
@ 2015-04-05 20:57   ` Jiri Kosina
  1 sibling, 0 replies; 27+ messages in thread
From: Jiri Kosina @ 2015-04-05 20:57 UTC (permalink / raw)
  To: Julia Lawall; +Cc: kernel-janitors, linux-input, linux-kernel

On Sun, 5 Apr 2015, Julia Lawall wrote:

> 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>

Applied to for-4.1/logitech, thanks.

-- 
Jiri Kosina
SUSE Labs

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

* Re: [PATCH 16/16] NFC: pn533: fix error return code
  2015-04-05 12:06 ` [PATCH 16/16] NFC: pn533: " Julia Lawall
@ 2015-04-05 23:23   ` Samuel Ortiz
  0 siblings, 0 replies; 27+ messages in thread
From: Samuel Ortiz @ 2015-04-05 23:23 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Lauro Ramos Venancio, kernel-janitors, Aloisio Almeida Jr,
	linux-wireless, linux-kernel

Hi Julia,

On Sun, Apr 05, 2015 at 02:06:36PM +0200, Julia Lawall wrote:
> 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>
> 
> ---
>  drivers/nfc/pn533.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
Applied, thanks.

Cheers,
Samuel.

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

* Re: [PATCH 14/16] soc: ti: knav_qmss_queue: fix error return code
  2015-04-05 12:06 ` [PATCH 14/16] soc: ti: knav_qmss_queue: " Julia Lawall
@ 2015-04-06  2:03   ` santosh.shilimkar
  0 siblings, 0 replies; 27+ messages in thread
From: santosh.shilimkar @ 2015-04-06  2:03 UTC (permalink / raw)
  To: linux-arm-kernel

On 4/5/15 5:06 AM, Julia Lawall wrote:
> 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>
>
> ---
Acked-by: Santosh Shilimkar <ssantosh@kernel.org>

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

* Re: [HPDD-discuss] [PATCH 15/16] staging: lustre: lnet: lnet: fix error return code
  2015-04-05 12:06 ` [PATCH 15/16] staging: lustre: lnet: lnet: " Julia Lawall
@ 2015-04-06  6:41   ` Zhen, Liang
  0 siblings, 0 replies; 27+ messages in thread
From: Zhen, Liang @ 2015-04-06  6:41 UTC (permalink / raw)
  To: Julia Lawall, Drokin, Oleg
  Cc: devel@driverdev.osuosl.org, Greg Kroah-Hartman,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	HPDD-discuss@lists.01.org

Julia, yes this is a bug that we have already fixed in the latest Lustre.
Sorry we haven¹t submitted this patch to kernel on time.

Thanks
Liang

On 4/5/15, 8:06 PM, "Julia Lawall" <Julia.Lawall@lip6.fr> wrote:

>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>
>
>---
> drivers/staging/lustre/lnet/lnet/api-ni.c |    8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c
>b/drivers/staging/lustre/lnet/lnet/api-ni.c
>index faceb95..4a14e51 100644
>--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
>+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
>@@ -650,15 +650,19 @@ lnet_prepare(lnet_pid_t requested_pid)
> 
> 	recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME, LNET_FL_MAX_MES,
> 					  sizeof(lnet_me_t));
>-	if (recs = NULL)
>+	if (recs = NULL) {
>+		rc = -ENOMEM;
> 		goto failed;
>+	}
> 
> 	the_lnet.ln_me_containers = recs;
> 
> 	recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD, LNET_FL_MAX_MDS,
> 					  sizeof(lnet_libmd_t));
>-	if (recs = NULL)
>+	if (recs = NULL) {
>+		rc = -ENOMEM;
> 		goto failed;
>+	}
> 
> 	the_lnet.ln_md_containers = recs;
> 
>
>_______________________________________________
>HPDD-discuss mailing list
>HPDD-discuss@lists.01.org
>https://lists.01.org/mailman/listinfo/hpdd-discuss

--
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] 27+ messages in thread

* Re: [PATCH 1/16] wan: lmc: fix error return code
  2015-04-05 12:06 ` [PATCH 1/16] wan: lmc: " Julia Lawall
@ 2015-04-07 19:26   ` David Miller
  0 siblings, 0 replies; 27+ messages in thread
From: David Miller @ 2015-04-07 19:26 UTC (permalink / raw)
  To: Julia.Lawall; +Cc: netdev, kernel-janitors, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Sun,  5 Apr 2015 14:06:21 +0200

> 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/)
 ...
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Applied.

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

* Re: [PATCH 8/16] cosa: fix error return code
  2015-04-05 12:06 ` [PATCH 8/16] cosa: " Julia Lawall
@ 2015-04-07 19:26   ` David Miller
  0 siblings, 0 replies; 27+ messages in thread
From: David Miller @ 2015-04-07 19:26 UTC (permalink / raw)
  To: Julia.Lawall; +Cc: kas, kernel-janitors, netdev, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Sun,  5 Apr 2015 14:06:28 +0200

> 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/)
 ...
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Applied.

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

end of thread, other threads:[~2015-04-07 19:26 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-05 12:06 [PATCH 0/16] fix error return code Julia Lawall
2015-04-05 12:06 ` [PATCH 1/16] wan: lmc: " Julia Lawall
2015-04-07 19:26   ` David Miller
2015-04-05 12:06 ` [PATCH 2/16] [media] si4713: " Julia Lawall
2015-04-05 12:06 ` [PATCH 4/16] [media] as102: " Julia Lawall
2015-04-05 12:06 ` [PATCH 3/16] [media] radio: " Julia Lawall
2015-04-05 12:06 ` [PATCH 5/16] ufs: " Julia Lawall
2015-04-05 12:06 ` [PATCH 6/16] HSI: cmt_speech: " Julia Lawall
2015-04-05 12:47   ` Sebastian Reichel
2015-04-05 12:06 ` [PATCH 7/16] parport_sunbpp: " Julia Lawall
2015-04-05 12:06 ` [PATCH 8/16] cosa: " Julia Lawall
2015-04-07 19:26   ` David Miller
2015-04-05 12:06 ` [PATCH 9/16] HID: logitech-hidpp: " Julia Lawall
2015-04-05 14:38   ` Benjamin Tissoires
2015-04-05 20:57   ` Jiri Kosina
2015-04-05 12:06 ` [PATCH 10/16] zram: " Julia Lawall
2015-04-05 12:06 ` [PATCH 11/16] drm/msm/dp: " Julia Lawall
2015-04-05 12:06 ` [PATCH 12/16] ib_srpt: " Julia Lawall
     [not found]   ` <1428235596-4757-13-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2015-04-05 16:27     ` Bart Van Assche
2015-04-05 12:06 ` [PATCH 13/16] ALSA: au1x00: " Julia Lawall
2015-04-05 16:06   ` [alsa-devel] " Takashi Iwai
2015-04-05 12:06 ` [PATCH 14/16] soc: ti: knav_qmss_queue: " Julia Lawall
2015-04-06  2:03   ` santosh.shilimkar
2015-04-05 12:06 ` [PATCH 15/16] staging: lustre: lnet: lnet: " Julia Lawall
2015-04-06  6:41   ` [HPDD-discuss] " Zhen, Liang
2015-04-05 12:06 ` [PATCH 16/16] NFC: pn533: " Julia Lawall
2015-04-05 23:23   ` Samuel Ortiz

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).