summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/max31790.c
diff options
context:
space:
mode:
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>2015-09-16 19:32:59 +0530
committerGuenter Roeck <linux@roeck-us.net>2015-10-14 07:57:14 -0700
commit791432cfd95bea3515f8cdfaf72ec263e5d3da80 (patch)
tree6ee42f86b2870a6956f7285aabcfd299f0597634 /drivers/hwmon/max31790.c
parent195a4b4298a7951c845dac2b326585c66add3435 (diff)
downloadlinux-791432cfd95bea3515f8cdfaf72ec263e5d3da80.tar.bz2
hwmon: (max31790) Fix dereference of ERR_PTR
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>
Diffstat (limited to 'drivers/hwmon/max31790.c')
-rw-r--r--drivers/hwmon/max31790.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c
index f1296680833a..69c0ac80a946 100644
--- a/drivers/hwmon/max31790.c
+++ b/drivers/hwmon/max31790.c
@@ -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);
@@ -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);