Skip to content

Commit

Permalink
hwmon: (emc2103) Fix use of an uninitilized variable in error case
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Guenter Roeck committed Jun 18, 2012
1 parent ac852ed commit 2355375
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/hwmon/emc2103.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,19 +451,23 @@ 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;
else
conf_reg &= ~0x80;

i2c_smbus_write_byte_data(client, REG_FAN_CONF1, conf_reg);

err:
mutex_unlock(&data->update_lock);
return count;
}
Expand Down

0 comments on commit 2355375

Please sign in to comment.