summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangjie Lu <kjlu@umn.edu>2018-12-21 13:10:39 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-02-12 19:46:08 +0100
commit1812be7e56c7c4447c2facdc52d81a872158a957 (patch)
tree6585faaecd695481b55da33685e83ea33d871f68
parent58ddc0c67d113a1081e3c017682b475b75a6bf2c (diff)
downloadlinux-exynos-1812be7e56c7c4447c2facdc52d81a872158a957.tar.gz
linux-exynos-1812be7e56c7c4447c2facdc52d81a872158a957.tar.bz2
linux-exynos-1812be7e56c7c4447c2facdc52d81a872158a957.zip
hwmon: (lm80) fix a missing check of bus read in lm80 probe
[ Upstream commit 9aa3aa15f4c2f74f47afd6c5db4b420fadf3f315 ] In lm80_probe(), if lm80_read_value() fails, it returns a negative error number which is stored to data->fan[f_min] and will be further used. We should avoid using the data if the read fails. The fix checks if lm80_read_value() fails, and if so, returns with the error number. Signed-off-by: Kangjie Lu <kjlu@umn.edu> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/hwmon/lm80.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index 04f9df0d2341..0e30fa00204c 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -628,6 +628,7 @@ static int lm80_probe(struct i2c_client *client,
struct device *dev = &client->dev;
struct device *hwmon_dev;
struct lm80_data *data;
+ int rv;
data = devm_kzalloc(dev, sizeof(struct lm80_data), GFP_KERNEL);
if (!data)
@@ -640,8 +641,14 @@ static int lm80_probe(struct i2c_client *client,
lm80_init_client(client);
/* A few vars need to be filled upon startup */
- data->fan[f_min][0] = lm80_read_value(client, LM80_REG_FAN_MIN(1));
- data->fan[f_min][1] = lm80_read_value(client, LM80_REG_FAN_MIN(2));
+ rv = lm80_read_value(client, LM80_REG_FAN_MIN(1));
+ if (rv < 0)
+ return rv;
+ data->fan[f_min][0] = rv;
+ rv = lm80_read_value(client, LM80_REG_FAN_MIN(2));
+ if (rv < 0)
+ return rv;
+ data->fan[f_min][1] = rv;
hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
data, lm80_groups);