lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20081203103051.f2f59c9f.sfr@canb.auug.org.au>
Date:	Wed, 3 Dec 2008 10:30:51 +1100
From:	Stephen Rothwell <sfr@...b.auug.org.au>
To:	Nicolas Palix <npalix@...u.dk>
Cc:	Jean Delvare <khali@...ux-fr.org>,
	Paul Mackerras <paulus@...ba.org>,
	Stelian Pop <stelian@...ies.net>, lm-sensors@...sensors.org,
	linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
	Julia Lawall <julia@...u.dk>
Subject: Re: [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@...u.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@...u.dk>
> Signed-off-by: Julia Lawall <julia@...u.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@...b.auug.org.au
http://www.canb.auug.org.au/~sfr/

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ