mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/6] fix error return code
@ 2012-08-05  9:52 Julia Lawall
  2012-08-05  9:52 ` [PATCH 1/6] drivers/edac/i7core_edac.c: " Julia Lawall
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Julia Lawall @ 2012-08-05  9:52 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors

These patches fix cases where the return code appears to be unintentially 0.

The complete semantic match that finds the problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
identifier f;
expression ret,e;
constant C;
@@

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

@s@
identifier r.f,ret;
@@

f(...) { <+... return ret; ...+> }

@@
identifier r.f,s.ret;
expression e,e1,e2,e3,e4,x;
@@

f(...) { <+...
(
if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
|
ret = 0
)
... when != ret = e1
*x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
... when != x = e2
    when != ret = e3
*if (x == NULL || ...)
{
  ... when != ret = e4
*  return ret;
}
...+> }
// </smpl>


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

* [PATCH 1/6] drivers/edac/i7core_edac.c: fix error return code
  2012-08-05  9:52 [PATCH 0/6] fix error return code Julia Lawall
@ 2012-08-05  9:52 ` Julia Lawall
  2012-08-05  9:52 ` [PATCH 2/6] drivers/cpufreq/pcc-cpufreq.c: " Julia Lawall
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2012-08-05  9:52 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: kernel-janitors, Doug Thompson, linux-edac, linux-kernel, Julia Lawall

From: Julia Lawall <julia@diku.dk>

Convert a 0 error return code to a negative one, as returned elsewhere in the
function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier ret;
expression e,e1,e2,e3,e4,x;
@@

(
if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
|
ret = 0
)
... when != ret = e1
*x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
... when != x = e2
    when != ret = e3
*if (x == NULL || ...)
{
  ... when != ret = e4
*  return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/edac/i7core_edac.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 3672101..64dcc98 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -1177,7 +1177,7 @@ static int i7core_create_sysfs_devices(struct mem_ctl_info *mci)
 
 	pvt->addrmatch_dev = kzalloc(sizeof(*pvt->addrmatch_dev), GFP_KERNEL);
 	if (!pvt->addrmatch_dev)
-		return rc;
+		return -ENOMEM;
 
 	pvt->addrmatch_dev->type = &addrmatch_type;
 	pvt->addrmatch_dev->bus = mci->dev.bus;
@@ -1198,7 +1198,7 @@ static int i7core_create_sysfs_devices(struct mem_ctl_info *mci)
 		if (!pvt->chancounts_dev) {
 			put_device(pvt->addrmatch_dev);
 			device_del(pvt->addrmatch_dev);
-			return rc;
+			return -ENOMEM;
 		}
 
 		pvt->chancounts_dev->type = &all_channel_counts_type;


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

* [PATCH 2/6] drivers/cpufreq/pcc-cpufreq.c: fix error return code
  2012-08-05  9:52 [PATCH 0/6] fix error return code Julia Lawall
  2012-08-05  9:52 ` [PATCH 1/6] drivers/edac/i7core_edac.c: " Julia Lawall
@ 2012-08-05  9:52 ` Julia Lawall
  2012-08-05 21:11   ` Rafael J. Wysocki
  2012-08-05  9:52 ` [PATCH 3/6] arch/powerpc/kvm/e500_tlb.c: " Julia Lawall
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2012-08-05  9:52 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: kernel-janitors, cpufreq, linux-pm, linux-kernel, Julia Lawall

From: Julia Lawall <julia@diku.dk>

Convert a 0 error return code to a negative one, as returned elsewhere in the
function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier ret;
expression e,e1,e2,e3,e4,x;
@@

(
if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
|
ret = 0
)
... when != ret = e1
*x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
... when != x = e2
    when != ret = e3
*if (x == NULL || ...)
{
  ... when != ret = e4
*  return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/cpufreq/pcc-cpufreq.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
index cdc02ac..503996a 100644
--- a/drivers/cpufreq/pcc-cpufreq.c
+++ b/drivers/cpufreq/pcc-cpufreq.c
@@ -454,6 +454,7 @@ static int __init pcc_cpufreq_probe(void)
 					mem_resource->address_length);
 	if (pcch_virt_addr == NULL) {
 		pr_debug("probe: could not map shared mem region\n");
+		ret = -ENOMEM;
 		goto out_free;
 	}
 	pcch_hdr = pcch_virt_addr;


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

* [PATCH 3/6] arch/powerpc/kvm/e500_tlb.c: fix error return code
  2012-08-05  9:52 [PATCH 0/6] fix error return code Julia Lawall
  2012-08-05  9:52 ` [PATCH 1/6] drivers/edac/i7core_edac.c: " Julia Lawall
  2012-08-05  9:52 ` [PATCH 2/6] drivers/cpufreq/pcc-cpufreq.c: " Julia Lawall
@ 2012-08-05  9:52 ` Julia Lawall
  2012-10-02 11:04   ` Alexander Graf
  2012-08-05  9:52 ` [PATCH 4/6] drivers/gpio/gpio-langwell.c: " Julia Lawall
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2012-08-05  9:52 UTC (permalink / raw)
  To: Alexander Graf
  Cc: kernel-janitors, Avi Kivity, Marcelo Tosatti,
	Benjamin Herrenschmidt, Paul Mackerras, kvm-ppc, kvm,
	linuxppc-dev, linux-kernel, Julia Lawall

From: Julia Lawall <julia@diku.dk>

Convert a 0 error return code to a negative one, as returned elsewhere in the
function.

A new label is also added to avoid freeing things that are known to not yet
be allocated.

A simplified version of the semantic match that finds the first problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier ret;
expression e,e1,e2,e3,e4,x;
@@

(
if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
|
ret = 0
)
... when != ret = e1
*x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
... when != x = e2
    when != ret = e3
*if (x == NULL || ...)
{
  ... when != ret = e4
*  return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 arch/powerpc/kvm/e500_tlb.c |   19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c
index c8f6c58..85fcdf7 100644
--- a/arch/powerpc/kvm/e500_tlb.c
+++ b/arch/powerpc/kvm/e500_tlb.c
@@ -1176,21 +1176,27 @@ int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
 	}
 
 	virt = vmap(pages, num_pages, VM_MAP, PAGE_KERNEL);
-	if (!virt)
+	if (!virt) {
+		ret = -ENOMEM;
 		goto err_put_page;
+	}
 
 	privs[0] = kzalloc(sizeof(struct tlbe_priv) * params.tlb_sizes[0],
 			   GFP_KERNEL);
 	privs[1] = kzalloc(sizeof(struct tlbe_priv) * params.tlb_sizes[1],
 			   GFP_KERNEL);
 
-	if (!privs[0] || !privs[1])
-		goto err_put_page;
+	if (!privs[0] || !privs[1]) {
+		ret = -ENOMEM;
+		goto err_privs;
+	}
 
 	g2h_bitmap = kzalloc(sizeof(u64) * params.tlb_sizes[1],
 	                     GFP_KERNEL);
-	if (!g2h_bitmap)
-		goto err_put_page;
+	if (!g2h_bitmap) {
+		ret = -ENOMEM;
+		goto err_privs;
+	}
 
 	free_gtlb(vcpu_e500);
 
@@ -1230,10 +1236,11 @@ int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
 	kvmppc_recalc_tlb1map_range(vcpu_e500);
 	return 0;
 
-err_put_page:
+err_privs:
 	kfree(privs[0]);
 	kfree(privs[1]);
 
+err_put_page:
 	for (i = 0; i < num_pages; i++)
 		put_page(pages[i]);
 

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

* [PATCH 4/6] drivers/gpio/gpio-langwell.c: fix error return code
  2012-08-05  9:52 [PATCH 0/6] fix error return code Julia Lawall
                   ` (2 preceding siblings ...)
  2012-08-05  9:52 ` [PATCH 3/6] arch/powerpc/kvm/e500_tlb.c: " Julia Lawall
@ 2012-08-05  9:52 ` Julia Lawall
  2012-08-05 19:10   ` Linus Walleij
  2012-08-05  9:52 ` [PATCH 5/6] drivers/char/tlclk.c: " Julia Lawall
  2012-08-05  9:52 ` [PATCH 6/6] drivers/atm/iphase.c: " Julia Lawall
  5 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2012-08-05  9:52 UTC (permalink / raw)
  To: Grant Likely; +Cc: kernel-janitors, Linus Walleij, linux-kernel, Julia Lawall

From: Julia Lawall <julia@diku.dk>

Convert a 0 error return code to a negative one, as returned elsewhere in the
function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier ret;
expression e,e1,e2,e3,e4,x;
@@

(
if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
|
ret = 0
)
... when != ret = e1
*x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
... when != x = e2
    when != ret = e3
*if (x == NULL || ...)
{
  ... when != ret = e4
*  return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/gpio/gpio-langwell.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-langwell.c b/drivers/gpio/gpio-langwell.c
index a1c8754..202a992 100644
--- a/drivers/gpio/gpio-langwell.c
+++ b/drivers/gpio/gpio-langwell.c
@@ -339,7 +339,7 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
 	resource_size_t start, len;
 	struct lnw_gpio *lnw;
 	u32 gpio_base;
-	int retval = 0;
+	int retval;
 	int ngpio = id->driver_data;
 
 	retval = pci_enable_device(pdev);
@@ -357,6 +357,7 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
 	base = ioremap_nocache(start, len);
 	if (!base) {
 		dev_err(&pdev->dev, "error mapping bar1\n");
+		retval = -EFAULT;
 		goto err3;
 	}
 	gpio_base = *((u32 *)base + 1);
@@ -381,8 +382,10 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
 
 	lnw->domain = irq_domain_add_linear(pdev->dev.of_node, ngpio,
 					    &lnw_gpio_irq_ops, lnw);
-	if (!lnw->domain)
+	if (!lnw->domain) {
+		retval = -ENOMEM;
 		goto err3;
+	}
 
 	lnw->reg_base = base;
 	lnw->chip.label = dev_name(&pdev->dev);


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

* [PATCH 5/6] drivers/char/tlclk.c: fix error return code
  2012-08-05  9:52 [PATCH 0/6] fix error return code Julia Lawall
                   ` (3 preceding siblings ...)
  2012-08-05  9:52 ` [PATCH 4/6] drivers/gpio/gpio-langwell.c: " Julia Lawall
@ 2012-08-05  9:52 ` Julia Lawall
  2012-08-06  3:22   ` Gross, Mark
  2012-08-05  9:52 ` [PATCH 6/6] drivers/atm/iphase.c: " Julia Lawall
  5 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2012-08-05  9:52 UTC (permalink / raw)
  To: Mark Gross
  Cc: kernel-janitors, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel,
	Julia Lawall

From: Julia Lawall <julia@diku.dk>

Convert a 0 error return code to a negative one, as returned elsewhere in the
function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier ret;
expression e,e1,e2,e3,e4,x;
@@

(
if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
|
ret = 0
)
... when != ret = e1
*x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
... when != x = e2
    when != ret = e3
*if (x == NULL || ...)
{
  ... when != ret = e4
*  return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

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

diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c
index ce29e7c..e95e0ab 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -784,8 +784,10 @@ static int __init tlclk_init(void)
 	}
 	tlclk_major = ret;
 	alarm_events = kzalloc( sizeof(struct tlclk_alarms), GFP_KERNEL);
-	if (!alarm_events)
+	if (!alarm_events) {
+		ret = -ENOMEM;
 		goto out1;
+	}
 
 	/* Read telecom clock IRQ number (Set by BIOS) */
 	if (!request_region(TLCLK_BASE, 8, "telco_clock")) {


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

* [PATCH 6/6] drivers/atm/iphase.c: fix error return code
  2012-08-05  9:52 [PATCH 0/6] fix error return code Julia Lawall
                   ` (4 preceding siblings ...)
  2012-08-05  9:52 ` [PATCH 5/6] drivers/char/tlclk.c: " Julia Lawall
@ 2012-08-05  9:52 ` Julia Lawall
  2012-08-06 20:30   ` David Miller
  5 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2012-08-05  9:52 UTC (permalink / raw)
  To: Chas Williams
  Cc: kernel-janitors, linux-atm-general, netdev, linux-kernel, Julia Lawall

From: Julia Lawall <julia@diku.dk>

Convert a 0 error return code to a negative one, as returned elsewhere in the
function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier ret;
expression e,e1,e2,e3,e4,x;
@@

(
if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
|
ret = 0
)
... when != ret = e1
*x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
... when != x = e2
    when != ret = e3
*if (x == NULL || ...)
{
  ... when != ret = e4
*  return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/atm/iphase.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index d438601..96cce6d 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -2362,7 +2362,7 @@ static int __devinit ia_init(struct atm_dev *dev)
 	{  
 		printk(DEV_LABEL " (itf %d): can't set up page mapping\n",  
 			    dev->number);  
-		return error;  
+		return -ENOMEM;
 	}  
 	IF_INIT(printk(DEV_LABEL " (itf %d): rev.%d,base=%p,irq=%d\n",  
 			dev->number, iadev->pci->revision, base, iadev->irq);)


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

* Re: [PATCH 4/6] drivers/gpio/gpio-langwell.c: fix error return code
  2012-08-05  9:52 ` [PATCH 4/6] drivers/gpio/gpio-langwell.c: " Julia Lawall
@ 2012-08-05 19:10   ` Linus Walleij
  0 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2012-08-05 19:10 UTC (permalink / raw)
  To: Julia Lawall, Mika Westerberg, Adrian Hunter
  Cc: Grant Likely, kernel-janitors, Linus Walleij, linux-kernel, Julia Lawall

On Sun, Aug 5, 2012 at 11:52 AM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:

> From: Julia Lawall <julia@diku.dk>
>
> Convert a 0 error return code to a negative one, as returned elsewhere in the
> function.

Patch applied.

Mika/Adrian: shout if this is incorrect.

Yours,
Linus Walleij

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

* Re: [PATCH 2/6] drivers/cpufreq/pcc-cpufreq.c: fix error return code
  2012-08-05  9:52 ` [PATCH 2/6] drivers/cpufreq/pcc-cpufreq.c: " Julia Lawall
@ 2012-08-05 21:11   ` Rafael J. Wysocki
  0 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2012-08-05 21:11 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kernel-janitors, cpufreq, linux-pm, linux-kernel, Julia Lawall

On Sunday, August 05, 2012, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> Convert a 0 error return code to a negative one, as returned elsewhere in the
> function.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> identifier ret;
> expression e,e1,e2,e3,e4,x;
> @@
> 
> (
> if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
> |
> ret = 0
> )
> ... when != ret = e1
> *x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
> ... when != x = e2
>     when != ret = e3
> *if (x == NULL || ...)
> {
>   ... when != ret = e4
> *  return ret;
> }
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>

Applied to the linux-next branch of the linux-pm.git tree.  I'm going to
push it as a fix for v3.6.

Thanks,
Rafael


> ---
>  drivers/cpufreq/pcc-cpufreq.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
> index cdc02ac..503996a 100644
> --- a/drivers/cpufreq/pcc-cpufreq.c
> +++ b/drivers/cpufreq/pcc-cpufreq.c
> @@ -454,6 +454,7 @@ static int __init pcc_cpufreq_probe(void)
>  					mem_resource->address_length);
>  	if (pcch_virt_addr == NULL) {
>  		pr_debug("probe: could not map shared mem region\n");
> +		ret = -ENOMEM;
>  		goto out_free;
>  	}
>  	pcch_hdr = pcch_virt_addr;
> 
> 
> 


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

* RE: [PATCH 5/6] drivers/char/tlclk.c: fix error return code
  2012-08-05  9:52 ` [PATCH 5/6] drivers/char/tlclk.c: " Julia Lawall
@ 2012-08-06  3:22   ` Gross, Mark
  0 siblings, 0 replies; 12+ messages in thread
From: Gross, Mark @ 2012-08-06  3:22 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kernel-janitors, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel,
	Julia Lawall

Acked-by <mark.gross@intel.com>

--mark
Ps sorry for the outlook munged reply.

-----Original Message-----
From: Julia Lawall [mailto:Julia.Lawall@lip6.fr] 
Sent: Sunday, August 05, 2012 2:53 AM
To: Gross, Mark
Cc: kernel-janitors@vger.kernel.org; Arnd Bergmann; Greg Kroah-Hartman; linux-kernel@vger.kernel.org; Julia Lawall
Subject: [PATCH 5/6] drivers/char/tlclk.c: fix error return code

From: Julia Lawall <julia@diku.dk>

Convert a 0 error return code to a negative one, as returned elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier ret;
expression e,e1,e2,e3,e4,x;
@@

(
if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
|
ret = 0
)
... when != ret = e1
*x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
... when != x = e2
    when != ret = e3
*if (x == NULL || ...)
{
  ... when != ret = e4
*  return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

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

diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c index ce29e7c..e95e0ab 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -784,8 +784,10 @@ static int __init tlclk_init(void)
 	}
 	tlclk_major = ret;
 	alarm_events = kzalloc( sizeof(struct tlclk_alarms), GFP_KERNEL);
-	if (!alarm_events)
+	if (!alarm_events) {
+		ret = -ENOMEM;
 		goto out1;
+	}
 
 	/* Read telecom clock IRQ number (Set by BIOS) */
 	if (!request_region(TLCLK_BASE, 8, "telco_clock")) {


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

* Re: [PATCH 6/6] drivers/atm/iphase.c: fix error return code
  2012-08-05  9:52 ` [PATCH 6/6] drivers/atm/iphase.c: " Julia Lawall
@ 2012-08-06 20:30   ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2012-08-06 20:30 UTC (permalink / raw)
  To: Julia.Lawall
  Cc: chas, kernel-janitors, linux-atm-general, netdev, linux-kernel, julia

From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Sun,  5 Aug 2012 11:52:36 +0200

> From: Julia Lawall <julia@diku.dk>
> 
> Convert a 0 error return code to a negative one, as returned elsewhere in the
> function.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
 ...
> Signed-off-by: Julia Lawall <julia@diku.dk>

Applied.

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

* Re: [PATCH 3/6] arch/powerpc/kvm/e500_tlb.c: fix error return code
  2012-08-05  9:52 ` [PATCH 3/6] arch/powerpc/kvm/e500_tlb.c: " Julia Lawall
@ 2012-10-02 11:04   ` Alexander Graf
  0 siblings, 0 replies; 12+ messages in thread
From: Alexander Graf @ 2012-10-02 11:04 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kernel-janitors, Avi Kivity, Marcelo Tosatti,
	Benjamin Herrenschmidt, Paul Mackerras, kvm-ppc, kvm,
	linuxppc-dev, linux-kernel, Julia Lawall


On 05.08.2012, at 11:52, Julia Lawall wrote:

> From: Julia Lawall <julia@diku.dk>
> 
> Convert a 0 error return code to a negative one, as returned elsewhere in the
> function.
> 
> A new label is also added to avoid freeing things that are known to not yet
> be allocated.
> 
> A simplified version of the semantic match that finds the first problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> identifier ret;
> expression e,e1,e2,e3,e4,x;
> @@
> 
> (
> if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
> |
> ret = 0
> )
> ... when != ret = e1
> *x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
> ... when != x = e2
>    when != ret = e3
> *if (x == NULL || ...)
> {
>  ... when != ret = e4
> *  return ret;
> }
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>

Thanks, applied to kvm-ppc-next.


Alex


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

end of thread, other threads:[~2012-10-02 11:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-05  9:52 [PATCH 0/6] fix error return code Julia Lawall
2012-08-05  9:52 ` [PATCH 1/6] drivers/edac/i7core_edac.c: " Julia Lawall
2012-08-05  9:52 ` [PATCH 2/6] drivers/cpufreq/pcc-cpufreq.c: " Julia Lawall
2012-08-05 21:11   ` Rafael J. Wysocki
2012-08-05  9:52 ` [PATCH 3/6] arch/powerpc/kvm/e500_tlb.c: " Julia Lawall
2012-10-02 11:04   ` Alexander Graf
2012-08-05  9:52 ` [PATCH 4/6] drivers/gpio/gpio-langwell.c: " Julia Lawall
2012-08-05 19:10   ` Linus Walleij
2012-08-05  9:52 ` [PATCH 5/6] drivers/char/tlclk.c: " Julia Lawall
2012-08-06  3:22   ` Gross, Mark
2012-08-05  9:52 ` [PATCH 6/6] drivers/atm/iphase.c: " Julia Lawall
2012-08-06 20:30   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®