Skip to content

Commit

Permalink
hwmon: (pwm-fan) Check return value from devm_add_action_or_reset
Browse files Browse the repository at this point in the history
devm_add_action_or_reset() can fail due to a memory allocation failure.
Check for it and return the error if that happens.

Fixes: 37bcec5 ("hwmon: (pwm-fan) Use devm_thermal_of_cooling_device_register")
Signed-off-by: Guenter Roeck <[email protected]>
  • Loading branch information
groeck committed Jun 24, 2019
1 parent b9bb92e commit 5696e4a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/hwmon/pwm-fan.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,10 @@ static int pwm_fan_probe(struct platform_device *pdev)
dev_err(dev, "Failed to enable fan supply: %d\n", ret);
return ret;
}
devm_add_action_or_reset(dev, pwm_fan_regulator_disable,
ctx->reg_en);
ret = devm_add_action_or_reset(dev, pwm_fan_regulator_disable,
ctx->reg_en);
if (ret)
return ret;
}

ctx->pwm_value = MAX_PWM;
Expand All @@ -337,7 +339,9 @@ static int pwm_fan_probe(struct platform_device *pdev)
return ret;
}
timer_setup(&ctx->rpm_timer, sample_timer, 0);
devm_add_action_or_reset(dev, pwm_fan_pwm_disable, ctx);
ret = devm_add_action_or_reset(dev, pwm_fan_pwm_disable, ctx);
if (ret)
return ret;

of_property_read_u32(dev->of_node, "pulses-per-revolution", &ppr);
ctx->pulses_per_revolution = ppr;
Expand Down

0 comments on commit 5696e4a

Please sign in to comment.