* [PATCH 1/7] drivers/macintosh/via-pmu-led.c: Add of_node_put to avoid memory leak
[not found] ` <1283075566-27441-1-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
@ 2010-08-29 9:52 ` Julia Lawall
2010-08-31 15:49 ` walter harms
2010-08-29 9:52 ` [PATCH 3/7] drivers/mtd/nand/mpc5121_nfc.c: " Julia Lawall
` (3 subsequent siblings)
4 siblings, 1 reply; 18+ messages in thread
From: Julia Lawall @ 2010-08-29 9:52 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Add a call to of_node_put in the error handling code following a call to
of_find_node_by_path.
The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
local idexpression x;
expression E,E1;
statement S;
@@
*x =
(of_find_node_by_path
|of_find_node_by_name
|of_find_node_by_phandle
|of_get_parent
|of_get_next_parent
|of_get_next_child
|of_find_compatible_node
|of_match_node
)(...);
...
if (x == NULL) S
<... when != x = E
*if (...) {
... when != of_node_put(x)
when != if (...) { ... of_node_put(x); ... }
(
return <+...x...+>;
|
* return ...;
)
}
...>
of_node_put(x);
// </smpl>
Signed-off-by: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
---
drivers/macintosh/via-pmu-led.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c
index d242976..19c3718 100644
--- a/drivers/macintosh/via-pmu-led.c
+++ b/drivers/macintosh/via-pmu-led.c
@@ -92,8 +92,10 @@ static int __init via_pmu_led_init(void)
if (dt == NULL)
return -ENODEV;
model = of_get_property(dt, "model", NULL);
- if (model == NULL)
+ if (model == NULL) {
+ of_node_put(dt);
return -ENODEV;
+ }
if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
strncmp(model, "iBook", strlen("iBook")) != 0 &&
strcmp(model, "PowerMac7,2") != 0 &&
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 1/7] drivers/macintosh/via-pmu-led.c: Add of_node_put to avoid memory leak
2010-08-29 9:52 ` [PATCH 1/7] drivers/macintosh/via-pmu-led.c: Add of_node_put to avoid memory leak Julia Lawall
@ 2010-08-31 15:49 ` walter harms
[not found] ` <4C7D247F.4060500-fPG8STNUNVg@public.gmane.org>
0 siblings, 1 reply; 18+ messages in thread
From: walter harms @ 2010-08-31 15:49 UTC (permalink / raw)
To: Julia Lawall
Cc: Benjamin Herrenschmidt, kernel-janitors, Grant Likely,
linuxppc-dev, linux-kernel, devicetree-discuss
Julia Lawall schrieb:
> Add a call to of_node_put in the error handling code following a call to
> of_find_node_by_path.
>
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @r exists@
> local idexpression x;
> expression E,E1;
> statement S;
> @@
>
> *x =
> (of_find_node_by_path
> |of_find_node_by_name
> |of_find_node_by_phandle
> |of_get_parent
> |of_get_next_parent
> |of_get_next_child
> |of_find_compatible_node
> |of_match_node
> )(...);
> ...
> if (x == NULL) S
> <... when != x = E
> *if (...) {
> ... when != of_node_put(x)
> when != if (...) { ... of_node_put(x); ... }
> (
> return <+...x...+>;
> |
> * return ...;
> )
> }
> ...>
> of_node_put(x);
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>
>
> ---
> drivers/macintosh/via-pmu-led.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c
> index d242976..19c3718 100644
> --- a/drivers/macintosh/via-pmu-led.c
> +++ b/drivers/macintosh/via-pmu-led.c
> @@ -92,8 +92,10 @@ static int __init via_pmu_led_init(void)
> if (dt == NULL)
> return -ENODEV;
> model = of_get_property(dt, "model", NULL);
> - if (model == NULL)
> + if (model == NULL) {
> + of_node_put(dt);
> return -ENODEV;
> + }
> if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
> strncmp(model, "iBook", strlen("iBook")) != 0 &&
> strcmp(model, "PowerMac7,2") != 0 &&
>
is there any rule that says when to use strncmp ? it seems perfecly valid to use strcpy here
(what is done in the last cmp).
re,
wh
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 3/7] drivers/mtd/nand/mpc5121_nfc.c: Add of_node_put to avoid memory leak
[not found] ` <1283075566-27441-1-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
2010-08-29 9:52 ` [PATCH 1/7] drivers/macintosh/via-pmu-led.c: Add of_node_put to avoid memory leak Julia Lawall
@ 2010-08-29 9:52 ` Julia Lawall
[not found] ` <1283075566-27441-4-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
2010-08-30 13:13 ` Artem Bityutskiy
2010-08-29 9:52 ` [PATCH 4/7] arch/powerpc/platforms/powermac/pfunc_core.c: " Julia Lawall
` (2 subsequent siblings)
4 siblings, 2 replies; 18+ messages in thread
From: Julia Lawall @ 2010-08-29 9:52 UTC (permalink / raw)
To: David Woodhouse
Cc: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Add a call to of_node_put in the error handling code following a call to
of_find_compatible_node.
The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
local idexpression x;
expression E,E1;
statement S;
@@
*x =
(of_find_node_by_path
|of_find_node_by_name
|of_find_node_by_phandle
|of_get_parent
|of_get_next_parent
|of_get_next_child
|of_find_compatible_node
|of_match_node
)(...);
...
if (x == NULL) S
<... when != x = E
*if (...) {
... when != of_node_put(x)
when != if (...) { ... of_node_put(x); ... }
(
return <+...x...+>;
|
* return ...;
)
}
...>
of_node_put(x);
// </smpl>
Signed-off-by: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
---
drivers/mtd/nand/mpc5121_nfc.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/mpc5121_nfc.c b/drivers/mtd/nand/mpc5121_nfc.c
index df0c1da..f4610bc 100644
--- a/drivers/mtd/nand/mpc5121_nfc.c
+++ b/drivers/mtd/nand/mpc5121_nfc.c
@@ -568,6 +568,7 @@ static int mpc5121_nfc_read_hw_config(struct mtd_info *mtd)
uint rcw_width;
uint rcwh;
uint romloc, ps;
+ int ret = 0;
rmnode = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-reset");
if (!rmnode) {
@@ -579,7 +580,8 @@ static int mpc5121_nfc_read_hw_config(struct mtd_info *mtd)
rm = of_iomap(rmnode, 0);
if (!rm) {
dev_err(prv->dev, "Error mapping reset module node!\n");
- return -EBUSY;
+ ret = -EBUSY;
+ goto out;
}
rcwh = in_be32(&rm->rcwhr);
@@ -628,8 +630,9 @@ static int mpc5121_nfc_read_hw_config(struct mtd_info *mtd)
rcw_width * 8, rcw_pagesize,
rcw_sparesize);
iounmap(rm);
+out:
of_node_put(rmnode);
- return 0;
+ return ret;
}
/* Free driver resources */
^ permalink raw reply related [flat|nested] 18+ messages in thread[parent not found: <1283075566-27441-4-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>]
* Re: [PATCH 3/7] drivers/mtd/nand/mpc5121_nfc.c: Add of_node_put to avoid memory leak
[not found] ` <1283075566-27441-4-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
@ 2010-08-29 15:47 ` Wolfram Sang
0 siblings, 0 replies; 18+ messages in thread
From: Wolfram Sang @ 2010-08-29 15:47 UTC (permalink / raw)
To: Julia Lawall
Cc: David Woodhouse, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ
[-- Attachment #1.1: Type: text/plain, Size: 2503 bytes --]
On Sun, Aug 29, 2010 at 11:52:42AM +0200, Julia Lawall wrote:
> Add a call to of_node_put in the error handling code following a call to
> of_find_compatible_node.
>
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @r exists@
> local idexpression x;
> expression E,E1;
> statement S;
> @@
>
> *x =
> (of_find_node_by_path
> |of_find_node_by_name
> |of_find_node_by_phandle
> |of_get_parent
> |of_get_next_parent
> |of_get_next_child
> |of_find_compatible_node
> |of_match_node
> )(...);
> ...
> if (x == NULL) S
> <... when != x = E
> *if (...) {
> ... when != of_node_put(x)
> when != if (...) { ... of_node_put(x); ... }
> (
> return <+...x...+>;
> |
> * return ...;
> )
> }
> ...>
> of_node_put(x);
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
Acked-by: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
adding ppc-list to cc.
>
> ---
> drivers/mtd/nand/mpc5121_nfc.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/nand/mpc5121_nfc.c b/drivers/mtd/nand/mpc5121_nfc.c
> index df0c1da..f4610bc 100644
> --- a/drivers/mtd/nand/mpc5121_nfc.c
> +++ b/drivers/mtd/nand/mpc5121_nfc.c
> @@ -568,6 +568,7 @@ static int mpc5121_nfc_read_hw_config(struct mtd_info *mtd)
> uint rcw_width;
> uint rcwh;
> uint romloc, ps;
> + int ret = 0;
>
> rmnode = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-reset");
> if (!rmnode) {
> @@ -579,7 +580,8 @@ static int mpc5121_nfc_read_hw_config(struct mtd_info *mtd)
> rm = of_iomap(rmnode, 0);
> if (!rm) {
> dev_err(prv->dev, "Error mapping reset module node!\n");
> - return -EBUSY;
> + ret = -EBUSY;
> + goto out;
> }
>
> rcwh = in_be32(&rm->rcwhr);
> @@ -628,8 +630,9 @@ static int mpc5121_nfc_read_hw_config(struct mtd_info *mtd)
> rcw_width * 8, rcw_pagesize,
> rcw_sparesize);
> iounmap(rm);
> +out:
> of_node_put(rmnode);
> - return 0;
> + return ret;
> }
>
> /* Free driver resources */
>
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
[-- Attachment #2: Type: text/plain, Size: 192 bytes --]
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/7] drivers/mtd/nand/mpc5121_nfc.c: Add of_node_put to avoid memory leak
2010-08-29 9:52 ` [PATCH 3/7] drivers/mtd/nand/mpc5121_nfc.c: " Julia Lawall
[not found] ` <1283075566-27441-4-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
@ 2010-08-30 13:13 ` Artem Bityutskiy
1 sibling, 0 replies; 18+ messages in thread
From: Artem Bityutskiy @ 2010-08-30 13:13 UTC (permalink / raw)
To: Julia Lawall
Cc: David Woodhouse, kernel-janitors, Grant Likely, linux-mtd,
linux-kernel, devicetree-discuss
On Sun, 2010-08-29 at 11:52 +0200, Julia Lawall wrote:
> Add a call to of_node_put in the error handling code following a call to
> of_find_compatible_node.
>
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
Pushed to l2-mtd-2.6.git / master, thanks.
--
Best Regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 4/7] arch/powerpc/platforms/powermac/pfunc_core.c: Add of_node_put to avoid memory leak
[not found] ` <1283075566-27441-1-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
2010-08-29 9:52 ` [PATCH 1/7] drivers/macintosh/via-pmu-led.c: Add of_node_put to avoid memory leak Julia Lawall
2010-08-29 9:52 ` [PATCH 3/7] drivers/mtd/nand/mpc5121_nfc.c: " Julia Lawall
@ 2010-08-29 9:52 ` Julia Lawall
2010-08-29 9:52 ` [PATCH 5/7] arch/powerpc/sysdev/qe_lib/qe.c: " Julia Lawall
2010-08-29 9:52 ` [PATCH 6/7] arch/powerpc/platforms/maple/setup.c: " Julia Lawall
4 siblings, 0 replies; 18+ messages in thread
From: Julia Lawall @ 2010-08-29 9:52 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ
Add a call to of_node_put in the error handling code following a call to
of_find_node_by_phandle.
The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
local idexpression x;
expression E,E1;
statement S;
@@
*x =
(of_find_node_by_path
|of_find_node_by_name
|of_find_node_by_phandle
|of_get_parent
|of_get_next_parent
|of_get_next_child
|of_find_compatible_node
|of_match_node
)(...);
...
if (x == NULL) S
<... when != x = E
*if (...) {
... when != of_node_put(x)
when != if (...) { ... of_node_put(x); ... }
(
return <+...x...+>;
|
* return ...;
)
}
...>
of_node_put(x);
// </smpl>
Signed-off-by: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
---
arch/powerpc/platforms/powermac/pfunc_core.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/platforms/powermac/pfunc_core.c b/arch/powerpc/platforms/powermac/pfunc_core.c
index cec6359..b0c3777 100644
--- a/arch/powerpc/platforms/powermac/pfunc_core.c
+++ b/arch/powerpc/platforms/powermac/pfunc_core.c
@@ -837,8 +837,10 @@ struct pmf_function *__pmf_find_function(struct device_node *target,
return NULL;
find_it:
dev = pmf_find_device(actor);
- if (dev == NULL)
- return NULL;
+ if (dev == NULL) {
+ result = NULL;
+ goto out;
+ }
list_for_each_entry(func, &dev->functions, link) {
if (name && strcmp(name, func->name))
@@ -850,8 +852,9 @@ struct pmf_function *__pmf_find_function(struct device_node *target,
result = func;
break;
}
- of_node_put(actor);
pmf_put_device(dev);
+out:
+ of_node_put(actor);
return result;
}
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 5/7] arch/powerpc/sysdev/qe_lib/qe.c: Add of_node_put to avoid memory leak
[not found] ` <1283075566-27441-1-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
` (2 preceding siblings ...)
2010-08-29 9:52 ` [PATCH 4/7] arch/powerpc/platforms/powermac/pfunc_core.c: " Julia Lawall
@ 2010-08-29 9:52 ` Julia Lawall
2010-08-30 20:39 ` Timur Tabi
[not found] ` <1283075566-27441-6-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
2010-08-29 9:52 ` [PATCH 6/7] arch/powerpc/platforms/maple/setup.c: " Julia Lawall
4 siblings, 2 replies; 18+ messages in thread
From: Julia Lawall @ 2010-08-29 9:52 UTC (permalink / raw)
To: Timur Tabi
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ
Add a call to of_node_put in the error handling code following a call to
of_find_compatible_node.
The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
local idexpression x;
expression E,E1;
statement S;
@@
*x =
(of_find_node_by_path
|of_find_node_by_name
|of_find_node_by_phandle
|of_get_parent
|of_get_next_parent
|of_get_next_child
|of_find_compatible_node
|of_match_node
)(...);
...
if (x == NULL) S
<... when != x = E
*if (...) {
... when != of_node_put(x)
when != if (...) { ... of_node_put(x); ... }
(
return <+...x...+>;
|
* return ...;
)
}
...>
of_node_put(x);
// </smpl>
Signed-off-by: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
---
arch/powerpc/sysdev/qe_lib/qe.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index 3da8014..90020de 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -640,6 +640,7 @@ unsigned int qe_get_num_of_snums(void)
if ((num_of_snums < 28) || (num_of_snums > QE_NUM_OF_SNUM)) {
/* No QE ever has fewer than 28 SNUMs */
pr_err("QE: number of snum is invalid\n");
+ of_node_put(qe);
return -EINVAL;
}
}
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 5/7] arch/powerpc/sysdev/qe_lib/qe.c: Add of_node_put to avoid memory leak
2010-08-29 9:52 ` [PATCH 5/7] arch/powerpc/sysdev/qe_lib/qe.c: " Julia Lawall
@ 2010-08-30 20:39 ` Timur Tabi
[not found] ` <1283075566-27441-6-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
1 sibling, 0 replies; 18+ messages in thread
From: Timur Tabi @ 2010-08-30 20:39 UTC (permalink / raw)
To: Julia Lawall
Cc: kernel-janitors, Benjamin Herrenschmidt, Paul Mackerras,
Grant Likely, linuxppc-dev, linux-kernel, devicetree-discuss
Julia Lawall wrote:
> Add a call to of_node_put in the error handling code following a call to
> of_find_compatible_node.
Acked-by: Timur Tabi <timur@freescale.com>
Thanks, Julia. Your work in finding these kinds of bugs is very much
appreciated.
^ permalink raw reply [flat|nested] 18+ messages in thread[parent not found: <1283075566-27441-6-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>]
* Re: [PATCH 5/7] arch/powerpc/sysdev/qe_lib/qe.c: Add of_node_put to avoid memory leak
[not found] ` <1283075566-27441-6-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
@ 2010-08-31 21:41 ` Kumar Gala
0 siblings, 0 replies; 18+ messages in thread
From: Kumar Gala @ 2010-08-31 21:41 UTC (permalink / raw)
To: Julia Lawall
Cc: linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Timur Tabi,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
On Aug 29, 2010, at 4:52 AM, Julia Lawall wrote:
> Add a call to of_node_put in the error handling code following a call to
> of_find_compatible_node.
>
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @r exists@
> local idexpression x;
> expression E,E1;
> statement S;
> @@
>
> *x =
> (of_find_node_by_path
> |of_find_node_by_name
> |of_find_node_by_phandle
> |of_get_parent
> |of_get_next_parent
> |of_get_next_child
> |of_find_compatible_node
> |of_match_node
> )(...);
> ...
> if (x == NULL) S
> <... when != x = E
> *if (...) {
> ... when != of_node_put(x)
> when != if (...) { ... of_node_put(x); ... }
> (
> return <+...x...+>;
> |
> * return ...;
> )
> }
> ...>
> of_node_put(x);
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
>
> ---
> arch/powerpc/sysdev/qe_lib/qe.c | 1 +
> 1 file changed, 1 insertion(+)
applied to merge
- k
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 6/7] arch/powerpc/platforms/maple/setup.c: Add of_node_put to avoid memory leak
[not found] ` <1283075566-27441-1-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
` (3 preceding siblings ...)
2010-08-29 9:52 ` [PATCH 5/7] arch/powerpc/sysdev/qe_lib/qe.c: " Julia Lawall
@ 2010-08-29 9:52 ` Julia Lawall
[not found] ` <1283075566-27441-7-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
4 siblings, 1 reply; 18+ messages in thread
From: Julia Lawall @ 2010-08-29 9:52 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ
Add a call to of_node_put in the error handling code following a call to
of_find_node_by_path.
The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
local idexpression x;
expression E,E1;
statement S;
@@
*x =
(of_find_node_by_path
|of_find_node_by_name
|of_find_node_by_phandle
|of_get_parent
|of_get_next_parent
|of_get_next_child
|of_find_compatible_node
|of_match_node
)(...);
...
if (x == NULL) S
<... when != x = E
*if (...) {
... when != of_node_put(x)
when != if (...) { ... of_node_put(x); ... }
(
return <+...x...+>;
|
* return ...;
)
}
...>
of_node_put(x);
// </smpl>
Signed-off-by: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
---
arch/powerpc/platforms/maple/setup.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index 3fff8d9..fe34c3d 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -358,6 +358,7 @@ static int __init maple_cpc925_edac_setup(void)
model = (const unsigned char *)of_get_property(np, "model", NULL);
if (!model) {
printk(KERN_ERR "%s: Unabel to get model info\n", __func__);
+ of_node_put(np);
return -ENODEV;
}
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 7/7] arch/powerpc/platforms/cell: Add of_node_put to avoid memory leak
[not found] <1283075566-27441-1-git-send-email-julia@diku.dk>
[not found] ` <1283075566-27441-1-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
@ 2010-08-29 9:52 ` Julia Lawall
2010-09-08 19:46 ` Grant Likely
1 sibling, 1 reply; 18+ messages in thread
From: Julia Lawall @ 2010-08-29 9:52 UTC (permalink / raw)
To: Arnd Bergmann
Cc: kernel-janitors, Benjamin Herrenschmidt, Paul Mackerras,
Grant Likely, linuxppc-dev, cbe-oss-dev, linux-kernel,
devicetree-discuss
Add calls to of_node_put in the error handling code following calls to
of_find_node_by_path and of_find_node_by_phandle.
The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
local idexpression x;
expression E,E1;
statement S;
@@
*x =
(of_find_node_by_path
|of_find_node_by_name
|of_find_node_by_phandle
|of_get_parent
|of_get_next_parent
|of_get_next_child
|of_find_compatible_node
|of_match_node
)(...);
...
if (x == NULL) S
<... when != x = E
*if (...) {
... when != of_node_put(x)
when != if (...) { ... of_node_put(x); ... }
(
return <+...x...+>;
|
* return ...;
)
}
...>
of_node_put(x);
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
arch/powerpc/platforms/cell/ras.c | 4 +++-
arch/powerpc/platforms/cell/spider-pic.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/cell/ras.c b/arch/powerpc/platforms/cell/ras.c
index 1d3c4ef..5ec1e47 100644
--- a/arch/powerpc/platforms/cell/ras.c
+++ b/arch/powerpc/platforms/cell/ras.c
@@ -173,8 +173,10 @@ static int __init cbe_ptcal_enable(void)
return -ENODEV;
size = of_get_property(np, "ibm,cbe-ptcal-size", NULL);
- if (!size)
+ if (!size) {
+ of_node_put(np);
return -ENODEV;
+ }
pr_debug("%s: enabling PTCAL, size = 0x%x\n", __func__, *size);
order = get_order(*size);
diff --git a/arch/powerpc/platforms/cell/spider-pic.c b/arch/powerpc/platforms/cell/spider-pic.c
index 5876e88..3f2e557 100644
--- a/arch/powerpc/platforms/cell/spider-pic.c
+++ b/arch/powerpc/platforms/cell/spider-pic.c
@@ -258,8 +258,10 @@ static unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic)
return NO_IRQ;
imap += intsize + 1;
tmp = of_get_property(iic, "#interrupt-cells", NULL);
- if (tmp == NULL)
+ if (tmp == NULL) {
+ of_node_put(iic);
return NO_IRQ;
+ }
intsize = *tmp;
/* Assume unit is last entry of interrupt specifier */
unit = imap[intsize - 1];
^ permalink raw reply related [flat|nested] 18+ messages in thread