Skip to contentSkip to conversation

fix error return code

PATCH Applied Julia Lawall 10 participants 27 messages Apr 5, 2015 – Apr 7, 2015

Subsystems (21)
lore
Share & tools
lore
#0 lore raw

cover fix error return code

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+=e1\|ret-=e1\)

    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+=e4\|ret-=e4\)

    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+=e1\|ret-=e1\|&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+=e1\|ret-=e1\)

    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>

#1 lore raw

PATCH 1/16 wan: lmc: fix error return code

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>

---
 drivers/net/wan/lmc/lmc_main.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/wan/lmc/lmc_main.c +1 -0
index bea0f31..317bc79 100644
@@ -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;
 	}
 
#3 lore raw

PATCH 2/16 si4713: fix error return code

In reply to Julia Lawall

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>

---
 drivers/media/radio/si4713/si4713.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/radio/si4713/si4713.c +3 -1
index c90004d..c4e1d6c 100644
@@ -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,
#4 lore raw

PATCH 3/16 radio: fix error return code

In reply to Julia Lawall

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>

---
 drivers/media/radio/radio-timb.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/radio/radio-timb.c +3 -1
index e6b55ed..04baafe 100644
@@ -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;
 
#5 lore raw

PATCH 4/16 as102: fix error return code

In reply to Julia Lawall

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>

---
 drivers/media/usb/as102/as102_drv.c |    1 +
 1 file changed, 1 insertion(+)
drivers/media/usb/as102/as102_drv.c +1 -0
index 8be1474..9dd7c7c 100644
@@ -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;
#6 lore raw

PATCH 5/16 ufs: fix error return code

In reply to Julia Lawall

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.

---
 drivers/scsi/ufs/ufshcd.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +3 -2
index 2aa85e3..8b802d1 100644
@@ -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 */
#7 lore raw

PATCH 6/16 HSI: cmt_speech: fix error return code

In reply to Julia Lawall

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>

---
 drivers/hsi/clients/cmt_speech.c |    1 +
 1 file changed, 1 insertion(+)
drivers/hsi/clients/cmt_speech.c +1 -0
index e9560ef..4983529 100644
@@ -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;
 	}
#9 lore raw

PATCH 7/16 parport_sunbpp: fix error return code

In reply to Julia Lawall

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.

---
 drivers/parport/parport_sunbpp.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/parport/parport_sunbpp.c +7 -2
index 01cf1c1..d7ad4b3 100644
@@ -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;
#10 lore raw

PATCH 8/16 cosa: fix error return code

In reply to Julia Lawall

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>

---
 drivers/net/wan/cosa.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/wan/cosa.c +1 -0
index 88d121d..bcfa01a 100644
@@ -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;
#12 lore raw

PATCH 9/16 HID: logitech-hidpp: fix error return code

In reply to Julia Lawall

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>

---
 drivers/hid/hid-logitech-hidpp.c |    1 +
 1 file changed, 1 insertion(+)
drivers/hid/hid-logitech-hidpp.c +1 -0
index e77658c..ce9819f 100644
@@ -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;
Reviewed-by on v1 9/16
#13 lore raw

Re: [PATCH 9/16] HID: logitech-hidpp: fix error return code

Quoted 25 lines · Julia Lawall

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>

Quoted 3 lines

---

Thanks!
Benjamin

Quoted 20 lines
 drivers/hid/hid-logitech-hidpp.c |    1 +
 1 file changed, 1 insertion(+)
drivers/hid/hid-logitech-hidpp.c +1 -1
index e77658c..ce9819f 100644
@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Applied
#14 lore raw

Re: [PATCH 9/16] HID: logitech-hidpp: fix error return code

In reply to Julia Lawall
Quoted 25 lines · Julia Lawall

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>

Quoted 1 line

Applied to for-4.1/logitech, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs
#15 lore raw

PATCH 10/16 zram: fix error return code

In reply to Julia Lawall

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>

---
 drivers/block/zram/zram_drv.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/block/zram/zram_drv.c +2 -0
index 759ee09..fe67ebb 100644
@@ -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;
 	}
 
#16 lore raw

PATCH 11/16 drm/msm/dp: fix error return code

In reply to Julia Lawall

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>

---
 drivers/gpu/drm/msm/edp/edp_ctrl.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/edp/edp_ctrl.c +2 -1
index 0ec5abd..29e52d7 100644
@@ -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;
 	}
 
#17 lore raw

PATCH 12/16 ib_srpt: fix error return code

In reply to Julia Lawall

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.

---
 drivers/infiniband/ulp/srpt/ib_srpt.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +4 -2
index 6e0a477..5ec98f5 100644
@@ -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;
#18 lore raw

Re: [PATCH 12/16] ib_srpt: fix error return code

Quoted 59 lines · Julia Lawall

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.

---
  drivers/infiniband/ulp/srpt/ib_srpt.c |    6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +3 -2
index 6e0a477..5ec98f5 100644
@@ -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;
  	}
 

drivers/infiniband/ulp/srpt/ib_srpt.c static int srpt_cm_req_recv(struct ib_cm_id *cm_id, · line 2605

Quoted 7 lines
drivers/infiniband/ulp/srpt/ib_srpt.c +1 -0
@@ -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.

#19 lore raw

PATCH 13/16 ALSA: au1x00: fix error return code

In reply to Julia Lawall

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>

---
 sound/mips/au1x00.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
sound/mips/au1x00.c +9 -3
index fbcaa54..1e30e84 100644
@@ -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),
Applied
#20 lore raw

Re: [alsa-devel] [PATCH 13/16] ALSA: au1x00: fix error return code

At Sun, 5 Apr 2015 14:06:33 +0200,

Quoted 26 lines · Julia Lawall

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>

Quoted 1 line

Applied, thanks.

Takashi

Quoted 44 lines
---
 sound/mips/au1x00.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
sound/mips/au1x00.c +9 -3
index fbcaa54..1e30e84 100644
@@ -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
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#21 lore raw

PATCH 14/16 soc: ti: knav_qmss_queue: fix error return code

In reply to Julia Lawall

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>

---
 drivers/soc/ti/knav_qmss_queue.c |    1 +
 1 file changed, 1 insertion(+)
drivers/soc/ti/knav_qmss_queue.c +1 -0
index 6d8646d..822ead8 100644
@@ -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);
Acked-by Santosh Shilimkar on v1 14/16
#22 lore raw

Re: [PATCH 14/16] soc: ti: knav_qmss_queue: fix error return code

Quoted 21 lines · Julia Lawall

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

return ret;
}
// </smpl>

---

#23 lore raw

PATCH 15/16 staging: lustre: lnet: lnet: fix error return code

In reply to Julia Lawall

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>

---
 drivers/staging/lustre/lnet/lnet/api-ni.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/staging/lustre/lnet/lnet/api-ni.c +6 -2
index faceb95..4a14e51 100644
@@ -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;
 
#24 lore raw

Re: [HPDD-discuss] [PATCH 15/16] staging: lustre: lnet: lnet: fix error return code

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

Quoted 59 lines · Julia Lawall

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>

---
drivers/staging/lustre/lnet/lnet/api-ni.c | 8 ++++++--

1 file changed, 6 insertions(+), 2 deletions(-)
drivers/staging/lustre/lnet/lnet/api-ni.c +6 -2
index faceb95..4a14e51 100644
@@ -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;
 
Quoted 4 lines

_______________________________________________
HPDD-discuss mailing list
[email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#25 lore raw

PATCH 16/16 NFC: pn533: fix error return code

In reply to Julia Lawall

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>

---
 drivers/nfc/pn533.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nfc/pn533.c +3 -1
index d46a700..732e607 100644
@@ -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);
Applied
#26 lore raw

Re: [PATCH 16/16] NFC: pn533: fix error return code

Hi Julia,

Quoted 25 lines · Julia Lawall

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>

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

Applied, thanks.

Cheers,
Samuel.