summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 19:16:32 +0200
committerGuenter Roeck <linux@roeck-us.net>2012-06-18 17:48:00 +0200
commit2355375efdf10f43680d420023baa97796bfcdff (patch)
tree9df2ed9840eaffdc1de36aae951244457d668cfd
parenthwmon: (applesmc) Limit key length in warning messages (diff)
downloadlinux-2355375efdf10f43680d420023baa97796bfcdff.tar.xz
linux-2355375efdf10f43680d420023baa97796bfcdff.zip
hwmon: (emc2103) Fix use of an uninitilized variable in error case
Fix: emc2103.c: In function set_pwm_enable: emc2103.c:463:12: warning: conf_reg may be used uninitialized in this function by checking the return value from read_u8_from_i2c(). This fixes a real problem, as conf_reg is really uninitialized if read_u8_from_i2c returns an error. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Robert Coulson <robert.coulson@ericsson.com> Acked-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r--drivers/hwmon/emc2103.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
index 9691f664c76e..e7d234b59312 100644
--- a/drivers/hwmon/emc2103.c
+++ b/drivers/hwmon/emc2103.c
@@ -451,11 +451,15 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *da,
data->fan_rpm_control = true;
break;
default:
- mutex_unlock(&data->update_lock);
- return -EINVAL;
+ count = -EINVAL;
+ goto err;
}
- read_u8_from_i2c(client, REG_FAN_CONF1, &conf_reg);
+ result = read_u8_from_i2c(client, REG_FAN_CONF1, &conf_reg);
+ if (result) {
+ count = result;
+ goto err;
+ }
if (data->fan_rpm_control)
conf_reg |= 0x80;
@@ -463,7 +467,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *da,
conf_reg &= ~0x80;
i2c_smbus_write_byte_data(client, REG_FAN_CONF1, conf_reg);
-
+err:
mutex_unlock(&data->update_lock);
return count;
}