hwmon: (max31790) potential ERR_PTR dereference

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

Fixes: 54187ff9d7 ('hwmon: (max31790) Convert to use new hwmon registration API')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Dan Carpenter 2016-10-12 09:24:52 +03:00 committed by Guenter Roeck
parent 667f4bab81
commit 94cdc5608b
1 changed files with 3 additions and 1 deletions

View File

@ -268,11 +268,13 @@ static int max31790_read_pwm(struct device *dev, u32 attr, int channel,
long *val)
{
struct max31790_data *data = max31790_update_device(dev);
u8 fan_config = data->fan_config[channel];
u8 fan_config;
if (IS_ERR(data))
return PTR_ERR(data);
fan_config = data->fan_config[channel];
switch (attr) {
case hwmon_pwm_input:
*val = data->pwm[channel] >> 8;