From be9d6374a76ffbeda783a5bdcb00e219c7bda2d0 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 25 Jul 2016 14:47:18 -0700 Subject: hwmon: (lm90) Add missing assignment Coverity reports the following error. >>> CID 1364474: Error handling issues (CHECKED_RETURN) >>> Calling "lm90_read_reg" without checking return value (as is done >>> elsewhere 28 out of 29 times). 532 lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH); 533 if (val < 0) 534 return val; Fixes: 10bfef47bd259 ("hwmon: (lm90) Read limit registers only once") Reviewed-by: Jean Delvare Signed-off-by: Guenter Roeck --- drivers/hwmon/lm90.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/hwmon/lm90.c') diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index f51e758ba529..7b3eedf76c62 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -529,7 +529,7 @@ static int lm90_update_limits(struct device *dev) return val; data->temp_hyst = val; - lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH); + val = lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH); if (val < 0) return val; data->temp11[REMOTE_LOW] = val << 8; -- cgit v1.2.3 From c5fcf01bcfceb245da575cc5bfa4391642649f2d Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 25 Jul 2016 14:53:23 -0700 Subject: hwmon: (lm90) Improve error handling Replace devm_add_action() with devm_add_action_or_reset(), and check its return value. Reviewed-by: Jean Delvare Signed-off-by: Guenter Roeck --- drivers/hwmon/lm90.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'drivers/hwmon/lm90.c') diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 7b3eedf76c62..fa15f7238a28 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -1551,9 +1551,7 @@ static int lm90_init_client(struct i2c_client *client, struct lm90_data *data) if (config != data->config_orig) /* Only write if changed */ i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); - devm_add_action(&client->dev, lm90_restore_conf, data); - - return 0; + return devm_add_action_or_reset(&client->dev, lm90_restore_conf, data); } static bool lm90_is_tripped(struct i2c_client *client, u16 *status) @@ -1640,7 +1638,9 @@ static int lm90_probe(struct i2c_client *client, return err; } - devm_add_action(dev, lm90_regulator_disable, regulator); + err = devm_add_action_or_reset(dev, lm90_regulator_disable, regulator); + if (err) + return err; data = devm_kzalloc(dev, sizeof(struct lm90_data), GFP_KERNEL); if (!data) @@ -1696,7 +1696,9 @@ static int lm90_probe(struct i2c_client *client, err = device_create_file(dev, &dev_attr_pec); if (err) return err; - devm_add_action(dev, lm90_remove_pec, dev); + err = devm_add_action_or_reset(dev, lm90_remove_pec, dev); + if (err) + return err; } hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, -- cgit v1.2.3