Skip to contentSkip to conversation

misc/ics932s401: Add a missing check to i2c_smbus_read_word_data

PATCH New Aditya Pakki 1 participant 1 message Dec 24, 2018 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 misc/ics932s401: Add a missing check to i2c_smbus_read_word_data

ics932s401_update_device may fail reading in i2c_smbus_read_word_data due to error in i2c_smbus_xfer. The fix checks the status and defaults the register to 0.

---
 drivers/misc/ics932s401.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/misc/ics932s401.c +2 -0
index 81a0541ef3ac..294fb2f66bfe 100644
@@ -146,6 +146,8 @@ static struct ics932s401_data *ics932s401_update_device(struct device *dev)
 	 */
 	for (i = 0; i < NUM_MIRRORED_REGS; i++) {
 		temp = i2c_smbus_read_word_data(client, regs_to_copy[i]);
+		if (temp < 0)
+			data->regs[regs_to_copy[i]] = 0;
 		data->regs[regs_to_copy[i]] = temp >> 8;
 	}
 
Signature · 1 line
2.17.1