Commit 94cdc560 authored by Dan Carpenter's avatar Dan Carpenter Committed by Guenter Roeck

hwmon: (max31790) potential ERR_PTR dereference

We should only dereference "data" after we check if it is an error
pointer.

Fixes: 54187ff9 ('hwmon: (max31790) Convert to use new hwmon registration API')
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 667f4bab
...@@ -268,11 +268,13 @@ static int max31790_read_pwm(struct device *dev, u32 attr, int channel, ...@@ -268,11 +268,13 @@ static int max31790_read_pwm(struct device *dev, u32 attr, int channel,
long *val) long *val)
{ {
struct max31790_data *data = max31790_update_device(dev); struct max31790_data *data = max31790_update_device(dev);
u8 fan_config = data->fan_config[channel]; u8 fan_config;
if (IS_ERR(data)) if (IS_ERR(data))
return PTR_ERR(data); return PTR_ERR(data);
fan_config = data->fan_config[channel];
switch (attr) { switch (attr) {
case hwmon_pwm_input: case hwmon_pwm_input:
*val = data->pwm[channel] >> 8; *val = data->pwm[channel] >> 8;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment