Skip to contentSkip to conversation

hwmon: ADT7410: handle errors from adt7410_update_device()

PATCH Applied Dan Carpenter 2 participants 2 messages Aug 15, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: ADT7410: handle errors from adt7410_update_device()

Smatch complains that adt7410_update_device() can return error pointers.

---
Only needed in linux-next.

drivers/hwmon/adt7410.c +7 -2
index f8606df..030c8d7 100644
@@ -236,9 +236,14 @@ static ssize_t adt7410_show_t_hyst(struct device *dev,
 				   char *buf)
 {
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
-	struct adt7410_data *data = adt7410_update_device(dev);
+	struct adt7410_data *data;
 	int nr = attr->index;
-	int hyst = (data->hyst & ADT7410_T_HYST_MASK) * 1000;
+	int hyst;
+
+	data = adt7410_update_device(dev);
+	if (IS_ERR(data))
+		return PTR_ERR(data);
+	hyst = (data->hyst & ADT7410_T_HYST_MASK) * 1000;
 
 	/*
 	 * hysteresis is stored as a 4 bit offset in the device, convert it
maintainer Applied
#1 lore raw
Quoted 15 lines · Dan Carpenter

Smatch complains that adt7410_update_device() can return error pointers.

---
Only needed in linux-next.

drivers/hwmon/adt7410.c +0 -1
index f8606df..030c8d7 100644
@@ -236,9 +236,14 @@ static ssize_t adt7410_show_t_hyst(struct device *dev,
 				   char *buf)
 {
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
-	struct adt7410_data *data = adt7410_update_device(dev);

drivers/hwmon/adt7410.c static ssize_t adt7410_show_t_hyst(struct device *dev, · line 247

Quoted 10 lines
drivers/hwmon/adt7410.c +7 -1
+	struct adt7410_data *data;
 	int nr = attr->index;
-	int hyst = (data->hyst & ADT7410_T_HYST_MASK) * 1000;
+	int hyst;
+
+	data = adt7410_update_device(dev);
+	if (IS_ERR(data))
+		return PTR_ERR(data);
+	hyst = (data->hyst & ADT7410_T_HYST_MASK) * 1000;
 

Hi Dan,

That should teach me to run smatch on new code :).

Applied, thanks a lot!

Guenter