@@ -942,6 +942,9 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr,
942942 int index = sattr -> index ;
943943 int nr = sattr -> nr ;
944944
945+ if (IS_ERR (data ))
946+ return PTR_ERR (data );
947+
945948 return sprintf (buf , "%d\n" , in_from_reg (data , nr , data -> in [nr ][index ]));
946949}
947950
@@ -1030,6 +1033,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
10301033 int index = sattr -> index ;
10311034 struct it87_data * data = it87_update_device (dev );
10321035
1036+ if (IS_ERR (data ))
1037+ return PTR_ERR (data );
1038+
10331039 return sprintf (buf , "%d\n" , TEMP_FROM_REG (data -> temp [nr ][index ]));
10341040}
10351041
@@ -1104,8 +1110,13 @@ static ssize_t show_temp_type(struct device *dev, struct device_attribute *attr,
11041110 struct sensor_device_attribute * sensor_attr = to_sensor_dev_attr (attr );
11051111 int nr = sensor_attr -> index ;
11061112 struct it87_data * data = it87_update_device (dev );
1107- u8 reg = data -> sensor ; /* In case value is updated while used */
1108- u8 extra = data -> extra ;
1113+ u8 reg , extra ;
1114+
1115+ if (IS_ERR (data ))
1116+ return PTR_ERR (data );
1117+
1118+ reg = data -> sensor ; /* In case value is updated while used */
1119+ extra = data -> extra ;
11091120
11101121 if ((has_temp_peci (data , nr ) && (reg >> 6 == nr + 1 )) ||
11111122 (has_temp_old_peci (data , nr ) && (extra & 0x80 )))
@@ -1197,6 +1208,9 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr,
11971208 int speed ;
11981209 struct it87_data * data = it87_update_device (dev );
11991210
1211+ if (IS_ERR (data ))
1212+ return PTR_ERR (data );
1213+
12001214 speed = has_16bit_fans (data ) ?
12011215 FAN16_FROM_REG (data -> fan [nr ][index ]) :
12021216 FAN_FROM_REG (data -> fan [nr ][index ],
@@ -1211,6 +1225,9 @@ static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr,
12111225 struct it87_data * data = it87_update_device (dev );
12121226 int nr = sensor_attr -> index ;
12131227
1228+ if (IS_ERR (data ))
1229+ return PTR_ERR (data );
1230+
12141231 return sprintf (buf , "%lu\n" , DIV_FROM_REG (data -> fan_div [nr ]));
12151232}
12161233
@@ -1221,6 +1238,9 @@ static ssize_t show_pwm_enable(struct device *dev,
12211238 struct it87_data * data = it87_update_device (dev );
12221239 int nr = sensor_attr -> index ;
12231240
1241+ if (IS_ERR (data ))
1242+ return PTR_ERR (data );
1243+
12241244 return sprintf (buf , "%d\n" , pwm_mode (data , nr ));
12251245}
12261246
@@ -1231,6 +1251,9 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr,
12311251 struct it87_data * data = it87_update_device (dev );
12321252 int nr = sensor_attr -> index ;
12331253
1254+ if (IS_ERR (data ))
1255+ return PTR_ERR (data );
1256+
12341257 return sprintf (buf , "%d\n" ,
12351258 pwm_from_reg (data , data -> pwm_duty [nr ]));
12361259}
@@ -1244,6 +1267,9 @@ static ssize_t show_pwm_freq(struct device *dev, struct device_attribute *attr,
12441267 unsigned int freq ;
12451268 int index ;
12461269
1270+ if (IS_ERR (data ))
1271+ return PTR_ERR (data );
1272+
12471273 if (has_pwm_freq2 (data ) && nr == 1 )
12481274 index = (data -> extra >> 4 ) & 0x07 ;
12491275 else
@@ -1531,6 +1557,9 @@ static ssize_t show_pwm_temp_map(struct device *dev,
15311557 int nr = sensor_attr -> index ;
15321558 int map ;
15331559
1560+ if (IS_ERR (data ))
1561+ return PTR_ERR (data );
1562+
15341563 map = data -> pwm_temp_map [nr ];
15351564 if (map >= 3 )
15361565 map = 0 ; /* Should never happen */
@@ -1595,6 +1624,9 @@ static ssize_t show_auto_pwm(struct device *dev, struct device_attribute *attr,
15951624 int nr = sensor_attr -> nr ;
15961625 int point = sensor_attr -> index ;
15971626
1627+ if (IS_ERR (data ))
1628+ return PTR_ERR (data );
1629+
15981630 return sprintf (buf , "%d\n" ,
15991631 pwm_from_reg (data , data -> auto_pwm [nr ][point ]));
16001632}
@@ -1631,6 +1663,9 @@ static ssize_t show_auto_pwm_slope(struct device *dev,
16311663 struct sensor_device_attribute * sensor_attr = to_sensor_dev_attr (attr );
16321664 int nr = sensor_attr -> index ;
16331665
1666+ if (IS_ERR (data ))
1667+ return PTR_ERR (data );
1668+
16341669 return sprintf (buf , "%d\n" , data -> auto_pwm [nr ][1 ] & 0x7f );
16351670}
16361671
@@ -1664,6 +1699,9 @@ static ssize_t show_auto_temp(struct device *dev, struct device_attribute *attr,
16641699 int point = sensor_attr -> index ;
16651700 int reg ;
16661701
1702+ if (IS_ERR (data ))
1703+ return PTR_ERR (data );
1704+
16671705 if (has_old_autopwm (data ) || point )
16681706 reg = data -> auto_temp [nr ][point ];
16691707 else
@@ -1884,6 +1922,9 @@ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,
18841922{
18851923 struct it87_data * data = it87_update_device (dev );
18861924
1925+ if (IS_ERR (data ))
1926+ return PTR_ERR (data );
1927+
18871928 return sprintf (buf , "%u\n" , data -> alarms );
18881929}
18891930static DEVICE_ATTR_RO (alarms );
@@ -1894,6 +1935,9 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
18941935 struct it87_data * data = it87_update_device (dev );
18951936 int bitnr = to_sensor_dev_attr (attr )-> index ;
18961937
1938+ if (IS_ERR (data ))
1939+ return PTR_ERR (data );
1940+
18971941 return sprintf (buf , "%u\n" , (data -> alarms >> bitnr ) & 1 );
18981942}
18991943
@@ -1949,6 +1993,9 @@ static ssize_t show_beep(struct device *dev, struct device_attribute *attr,
19491993 struct it87_data * data = it87_update_device (dev );
19501994 int bitnr = to_sensor_dev_attr (attr )-> index ;
19511995
1996+ if (IS_ERR (data ))
1997+ return PTR_ERR (data );
1998+
19521999 return sprintf (buf , "%u\n" , (data -> beeps >> bitnr ) & 1 );
19532000}
19542001
@@ -2022,6 +2069,9 @@ static ssize_t cpu0_vid_show(struct device *dev,
20222069{
20232070 struct it87_data * data = it87_update_device (dev );
20242071
2072+ if (IS_ERR (data ))
2073+ return PTR_ERR (data );
2074+
20252075 return sprintf (buf , "%ld\n" , (long )vid_from_reg (data -> vid , data -> vrm ));
20262076}
20272077static DEVICE_ATTR_RO (cpu0_vid );
0 commit comments