* [lm-sensors] [PATCH] hwmon: (ds620): Check data pointer before dereference it
@ 2014-07-12 8:55 Axel Lin
2014-07-12 14:24 ` Guenter Roeck
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Axel Lin @ 2014-07-12 8:55 UTC (permalink / raw)
To: lm-sensors
data can be an ERR_PTR, so the client assignment must only happen after the
ERR_PTR check.
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/hwmon/ds620.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c
index 1bdb6246..65e01a8 100644
--- a/drivers/hwmon/ds620.c
+++ b/drivers/hwmon/ds620.c
@@ -159,7 +159,12 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct ds620_data *data = dev_get_drvdata(dev);
- struct i2c_client *client = data->client;
+ struct i2c_client *client;
+
+ if (IS_ERR(data))
+ return PTR_ERR(data);
+
+ client = data->client;
res = kstrtol(buf, 10, &val);
@@ -181,13 +186,15 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct ds620_data *data = ds620_update_client(dev);
- struct i2c_client *client = data->client;
+ struct i2c_client *client;
u16 conf, new_conf;
int res;
if (IS_ERR(data))
return PTR_ERR(data);
+ client = data->client;
+
/* reset alarms if necessary */
res = i2c_smbus_read_word_swapped(client, DS620_REG_CONF);
if (res < 0)
--
1.9.1
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [lm-sensors] [PATCH] hwmon: (ds620): Check data pointer before dereference it
2014-07-12 8:55 [lm-sensors] [PATCH] hwmon: (ds620): Check data pointer before dereference it Axel Lin
@ 2014-07-12 14:24 ` Guenter Roeck
2014-07-12 15:00 ` Guenter Roeck
2014-07-12 21:49 ` Axel Lin
2 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2014-07-12 14:24 UTC (permalink / raw)
To: lm-sensors
On 07/12/2014 01:55 AM, Axel Lin wrote:
> data can be an ERR_PTR, so the client assignment must only happen after the
> ERR_PTR check.
>
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> drivers/hwmon/ds620.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c
> index 1bdb6246..65e01a8 100644
> --- a/drivers/hwmon/ds620.c
> +++ b/drivers/hwmon/ds620.c
> @@ -159,7 +159,12 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
>
> struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
> struct ds620_data *data = dev_get_drvdata(dev);
> - struct i2c_client *client = data->client;
> + struct i2c_client *client;
> +
> + if (IS_ERR(data))
> + return PTR_ERR(data);
> +
Hi Axel,
This check is not needed; data is from dev_get_drvdata() and that is not problematic.
Guenter
> + client = data->client;
>
> res = kstrtol(buf, 10, &val);
>
> @@ -181,13 +186,15 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
> {
> struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
> struct ds620_data *data = ds620_update_client(dev);
> - struct i2c_client *client = data->client;
> + struct i2c_client *client;
> u16 conf, new_conf;
> int res;
>
> if (IS_ERR(data))
> return PTR_ERR(data);
>
> + client = data->client;
> +
> /* reset alarms if necessary */
> res = i2c_smbus_read_word_swapped(client, DS620_REG_CONF);
> if (res < 0)
>
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [lm-sensors] [PATCH] hwmon: (ds620): Check data pointer before dereference it
2014-07-12 8:55 [lm-sensors] [PATCH] hwmon: (ds620): Check data pointer before dereference it Axel Lin
2014-07-12 14:24 ` Guenter Roeck
@ 2014-07-12 15:00 ` Guenter Roeck
2014-07-12 21:49 ` Axel Lin
2 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2014-07-12 15:00 UTC (permalink / raw)
To: lm-sensors
On 07/12/2014 07:24 AM, Guenter Roeck wrote:
> On 07/12/2014 01:55 AM, Axel Lin wrote:
>> data can be an ERR_PTR, so the client assignment must only happen after the
>> ERR_PTR check.
>>
>> Reported-by: Guenter Roeck <linux@roeck-us.net>
>> Signed-off-by: Axel Lin <axel.lin@ingics.com>
>> ---
>> drivers/hwmon/ds620.c | 11 +++++++++--
>> 1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c
>> index 1bdb6246..65e01a8 100644
>> --- a/drivers/hwmon/ds620.c
>> +++ b/drivers/hwmon/ds620.c
>> @@ -159,7 +159,12 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
>>
>> struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
>> struct ds620_data *data = dev_get_drvdata(dev);
>> - struct i2c_client *client = data->client;
>> + struct i2c_client *client;
>> +
>> + if (IS_ERR(data))
>> + return PTR_ERR(data);
>> +
> Hi Axel,
>
> This check is not needed; data is from dev_get_drvdata() and that is not problematic.
>
Never mind, though. I fixed it up myself and merged it with the original devm conversion patch.
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [lm-sensors] [PATCH] hwmon: (ds620): Check data pointer before dereference it
2014-07-12 8:55 [lm-sensors] [PATCH] hwmon: (ds620): Check data pointer before dereference it Axel Lin
2014-07-12 14:24 ` Guenter Roeck
2014-07-12 15:00 ` Guenter Roeck
@ 2014-07-12 21:49 ` Axel Lin
2 siblings, 0 replies; 4+ messages in thread
From: Axel Lin @ 2014-07-12 21:49 UTC (permalink / raw)
To: lm-sensors
2014-07-12 23:00 GMT+08:00 Guenter Roeck <linux@roeck-us.net>:
> On 07/12/2014 07:24 AM, Guenter Roeck wrote:
>>
>> On 07/12/2014 01:55 AM, Axel Lin wrote:
>>>
>>> data can be an ERR_PTR, so the client assignment must only happen after
>>> the
>>> ERR_PTR check.
>>>
>>> Reported-by: Guenter Roeck <linux@roeck-us.net>
>>> Signed-off-by: Axel Lin <axel.lin@ingics.com>
>>> ---
>>> drivers/hwmon/ds620.c | 11 +++++++++--
>>> 1 file changed, 9 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c
>>> index 1bdb6246..65e01a8 100644
>>> --- a/drivers/hwmon/ds620.c
>>> +++ b/drivers/hwmon/ds620.c
>>> @@ -159,7 +159,12 @@ static ssize_t set_temp(struct device *dev, struct
>>> device_attribute *da,
>>>
>>> struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
>>> struct ds620_data *data = dev_get_drvdata(dev);
>>> - struct i2c_client *client = data->client;
>>> + struct i2c_client *client;
>>> +
>>> + if (IS_ERR(data))
>>> + return PTR_ERR(data);
>>> +
>>
>> Hi Axel,
>>
>> This check is not needed; data is from dev_get_drvdata() and that is not
>> problematic.
>>
>
> Never mind, though. I fixed it up myself and merged it with the original
> devm conversion patch.
Thank you, Guenter.
Axel
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-12 21:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-12 8:55 [lm-sensors] [PATCH] hwmon: (ds620): Check data pointer before dereference it Axel Lin
2014-07-12 14:24 ` Guenter Roeck
2014-07-12 15:00 ` Guenter Roeck
2014-07-12 21:49 ` Axel Lin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.