Skip to contentSkip to conversation

drivers: adt7470: check the return value of adt7470_read_temperatures

PATCH NAK Li Zhong 2 participants 2 messages Sep 21, 2022 Hardware monitoring

lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH 1/1 drivers: adt7470: check the return value of adt7470_read_temperatures

adt7470_read_temperatures() fails and returns error when operations on regmap fail. adt7470_update_thread() currently does not check for it and propagate the error.

---
 drivers/hwmon/adt7470.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/hwmon/adt7470.c +5 -1
index c67cd037a93f..0aadb2dc067f 100644
@@ -289,12 +289,16 @@ static int adt7470_update_thread(void *p)
 {
 	struct i2c_client *client = p;
 	struct adt7470_data *data = i2c_get_clientdata(client);
+	int err;
 
 	while (!kthread_should_stop()) {
 		mutex_lock(&data->lock);
-		adt7470_read_temperatures(data);
+		err = adt7470_read_temperatures(data);
 		mutex_unlock(&data->lock);
 
+		if (err)
+			return err;
+
 		if (kthread_should_stop())
 			break;
 
Signature · 1 line
2.25.1
maintainer NAK
#1 lore raw
Quoted 21 lines · Li Zhong

adt7470_read_temperatures() fails and returns error when operations on regmap fail. adt7470_update_thread() currently does not check for it and propagate the error.

---
  drivers/hwmon/adt7470.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
drivers/hwmon/adt7470.c +1 -0
index c67cd037a93f..0aadb2dc067f 100644
@@ -289,12 +289,16 @@ static int adt7470_update_thread(void *p)
  {
  	struct i2c_client *client = p;
  	struct adt7470_data *data = i2c_get_clientdata(client);
+	int err;
 
  	while (!kthread_should_stop()) {
  		mutex_lock(&data->lock);

drivers/hwmon/adt7470.c static int adt7470_update_thread(void *p) · line 304

Quoted 10 lines
drivers/hwmon/adt7470.c +4 -1
-		adt7470_read_temperatures(data);
+		err = adt7470_read_temperatures(data);
  		mutex_unlock(&data->lock);
 
+		if (err)
+			return err;
+
  		if (kthread_should_stop())
  			break;
 

NACK.

That is a kernel thread which should keep going even after an error. Aborting the thread after an error would be the absolute wrong thing to do.

Guenter