This is a note to let you know that I've just added the patch titled hwmon: (amc6821) Fix possible race condition bug to the 3.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: hwmon-amc6821-fix-possible-race-condition-bug.patch and it can be found in the queue-3.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From cf44819c98db11163f58f08b822d626c7a8f5188 Mon Sep 17 00:00:00 2001 From: Axel Lin <axel.lin@xxxxxxxxxx> Date: Thu, 31 Jul 2014 09:43:19 +0800 Subject: hwmon: (amc6821) Fix possible race condition bug From: Axel Lin <axel.lin@xxxxxxxxxx> commit cf44819c98db11163f58f08b822d626c7a8f5188 upstream. Ensure mutex lock protects the read-modify-write period to prevent possible race condition bug. In additional, update data->valid should also be protected by the mutex lock. Signed-off-by: Axel Lin <axel.lin@xxxxxxxxxx> Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/hwmon/amc6821.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) --- a/drivers/hwmon/amc6821.c +++ b/drivers/hwmon/amc6821.c @@ -360,11 +360,13 @@ static ssize_t set_pwm1_enable( if (config) return config; + mutex_lock(&data->update_lock); config = i2c_smbus_read_byte_data(client, AMC6821_REG_CONF1); if (config < 0) { dev_err(&client->dev, "Error reading configuration register, aborting.\n"); - return config; + count = config; + goto unlock; } switch (val) { @@ -381,14 +383,15 @@ static ssize_t set_pwm1_enable( config |= AMC6821_CONF1_FDRC1; break; default: - return -EINVAL; + count = -EINVAL; + goto unlock; } - mutex_lock(&data->update_lock); if (i2c_smbus_write_byte_data(client, AMC6821_REG_CONF1, config)) { dev_err(&client->dev, "Configuration register write error, aborting.\n"); count = -EIO; } +unlock: mutex_unlock(&data->update_lock); return count; } @@ -493,8 +496,9 @@ static ssize_t set_temp_auto_point_temp( return -EINVAL; } - data->valid = 0; mutex_lock(&data->update_lock); + data->valid = 0; + switch (ix) { case 0: ptemp[0] = clamp_val(val / 1000, 0, @@ -658,13 +662,14 @@ static ssize_t set_fan1_div( if (config) return config; + mutex_lock(&data->update_lock); config = i2c_smbus_read_byte_data(client, AMC6821_REG_CONF4); if (config < 0) { dev_err(&client->dev, "Error reading configuration register, aborting.\n"); - return config; + count = config; + goto EXIT; } - mutex_lock(&data->update_lock); switch (val) { case 2: config &= ~AMC6821_CONF4_PSPR; Patches currently in stable-queue which might be from axel.lin@xxxxxxxxxx are queue-3.14/hwmon-sis5595-prevent-overflow-problem-when-writing-large-limits.patch queue-3.14/hwmon-ads1015-fix-off-by-one-for-valid-channel-index-checking.patch queue-3.14/hwmon-lm78-fix-overflow-problems-seen-when-writing-large-temperature-limits.patch queue-3.14/hwmon-gpio-fan-prevent-overflow-problem-when-writing-large-limits.patch queue-3.14/hwmon-amc6821-fix-possible-race-condition-bug.patch queue-3.14/hwmon-ads1015-fix-out-of-bounds-array-access.patch queue-3.14/hwmon-dme1737-prevent-overflow-problem-when-writing-large-limits.patch queue-3.14/hwmon-lm85-fix-various-errors-on-attribute-writes.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html