Skip to content

Commit

Permalink
hwmon: (max31790) Fix dereference of ERR_PTR
Browse files Browse the repository at this point in the history
max31790_update_device() return the error code in ERR_PTR. We were
checking if it has returned error or not but before checking we have
dereferenced it.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Sudip Mukherjee authored and Guenter Roeck committed Oct 14, 2015
1 parent 195a4b4 commit 791432c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/hwmon/max31790.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ static ssize_t get_fan(struct device *dev,
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct max31790_data *data = max31790_update_device(dev);
int sr = get_tach_period(data->fan_dynamics[attr->index]);
int rpm;
int sr, rpm;

if (IS_ERR(data))
return PTR_ERR(data);

sr = get_tach_period(data->fan_dynamics[attr->index]);
rpm = RPM_FROM_REG(data->tach[attr->index], sr);

return sprintf(buf, "%d\n", rpm);
Expand All @@ -190,12 +190,12 @@ static ssize_t get_fan_target(struct device *dev,
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct max31790_data *data = max31790_update_device(dev);
int sr = get_tach_period(data->fan_dynamics[attr->index]);
int rpm;
int sr, rpm;

if (IS_ERR(data))
return PTR_ERR(data);

sr = get_tach_period(data->fan_dynamics[attr->index]);
rpm = RPM_FROM_REG(data->target_count[attr->index], sr);

return sprintf(buf, "%d\n", rpm);
Expand Down

0 comments on commit 791432c

Please sign in to comment.