Skip to content

Commit

Permalink
hwmon: (max31790) potential ERR_PTR dereference
Browse files Browse the repository at this point in the history
We should only dereference "data" after we check if it is an error
pointer.

Fixes: 54187ff ('hwmon: (max31790) Convert to use new hwmon registration API')
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Guenter Roeck <[email protected]>
  • Loading branch information
Dan Carpenter authored and groeck committed Oct 17, 2016
1 parent 667f4ba commit 94cdc56
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/hwmon/max31790.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 94cdc56

Please sign in to comment.