lkml.org 
[lkml]   [2008]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH linux-next] hwmon/ams: Add missing of_node_put in ams-core.c
On Tue, 2 Dec 2008 14:48:13 +0100 Nicolas Palix <npalix@diku.dk> wrote:
>
> of_node_put is needed before discarding a value received from
> of_find_node_by_name, eg in error handling code or when the device
> node is no longer used.
>
> Signed-off-by: Nicolas Palix <npalix@diku.dk>
> Signed-off-by: Julia Lawall <julia@diku.dk>
> ---
> drivers/hwmon/ams/ams-core.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/hwmon/ams/ams-core.c b/drivers/hwmon/ams/ams-core.c
> index 6c9ace1..e612af9 100644
> --- a/drivers/hwmon/ams/ams-core.c
> +++ b/drivers/hwmon/ams/ams-core.c
> @@ -202,6 +202,7 @@ int __init ams_init(void)
> if (np && of_device_is_compatible(np, "AAPL,accelerometer_1"))
> /* Found I2C motion sensor */
> return ams_i2c_init(np);
> + of_node_put(np);

This is wrong because if CONFIG_SENSORS_AMS_PMU is set, np is used again
below.

> #endif
>
> #ifdef CONFIG_SENSORS_AMS_PMU
> @@ -209,6 +210,7 @@ int __init ams_init(void)
> if (np && of_device_is_compatible(np, "sms"))
> /* Found PMU motion sensor */
> return ams_pmu_init(np);
> + of_node_put(np);
> #endif
> return -ENODEV;
> }

Also, I don't like this code since each of ams_i2c_init and ams_pmu_init
keep a reference to np, so they should be doing an of_node_get(np) and
this code above should be unconditionally doing an of_node_put(np). This
is not your problem, though.

--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2008-12-03 00:33    [W:0.031 / U:0.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site