lkml.org 
[lkml]   [2018]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] hwmon: (ina2xx) initialize mutex before locking
On Mon, Apr 16, 2018 at 10:08:19PM +0500, Ahsan Hussain wrote:
>
> Upstream commit
>
> 8d008c0c ("hwmon: (ina2xx) Make calibration register value fixed")
>
This doesn't have to be on separate lines; as written, it just causes
confusion.

> makes ina2xx_set_shunt() call mutex_lock on an un-initialized mutex.
> Initialize it prior so we don't get a NULL pointer dereference error
>
> Signed-off-by: Ahsan Hussain <ahsan_hussain@mentor.com>

Good find, but your patch is corrupted to the point where any attenpt to
fix it up on my side failed. Please resend without corruption, and please
provide a Fixes: line.

Thanks,
Guenter

> ---
> drivers/hwmon/ina2xx.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
> index a629f7c..1304f01 100644
> --- a/drivers/hwmon/ina2xx.c
> +++ b/drivers/hwmon/ina2xx.c
> @@ -457,6 +457,8 @@ static int ina2xx_probe(struct i2c_client *client,
> val = INA2XX_RSHUNT_DEFAULT;
> }
> + mutex_init(&data->config_lock);
> +
> ina2xx_set_shunt(data, val);
> ina2xx_regmap_config.max_register = data->config->registers;
> @@ -473,8 +475,6 @@ static int ina2xx_probe(struct i2c_client *client,
> return -ENODEV;
> }
> - mutex_init(&data->config_lock);
> -
> data->groups[group++] = &ina2xx_group;
> if (id->driver_data == ina226)
> data->groups[group++] = &ina226_group;
> --
> 2.7.4
>

\
 
 \ /
  Last update: 2018-04-16 19:29    [W:0.087 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site