diff options
author | Guenter Roeck <linux@roeck-us.net> | 2019-06-07 16:27:06 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2019-06-23 21:32:34 -0400 |
commit | 5696e4aaabf2a6bae0fe8b4abf17fe17c2b03beb (patch) | |
tree | f28c240ade7c7c6bc59aa862d670684c93080988 | |
parent | b9bb92e1d1be921e91d8b469dc1261ea5ac71991 (diff) |
hwmon: (pwm-fan) Check return value from devm_add_action_or_reset
devm_add_action_or_reset() can fail due to a memory allocation failure.
Check for it and return the error if that happens.
Fixes: 37bcec5d9f71 ("hwmon: (pwm-fan) Use devm_thermal_of_cooling_device_register")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/pwm-fan.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 08c9b9f1c16e..54c0ff00d67f 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c | |||
@@ -320,8 +320,10 @@ static int pwm_fan_probe(struct platform_device *pdev) | |||
320 | dev_err(dev, "Failed to enable fan supply: %d\n", ret); | 320 | dev_err(dev, "Failed to enable fan supply: %d\n", ret); |
321 | return ret; | 321 | return ret; |
322 | } | 322 | } |
323 | devm_add_action_or_reset(dev, pwm_fan_regulator_disable, | 323 | ret = devm_add_action_or_reset(dev, pwm_fan_regulator_disable, |
324 | ctx->reg_en); | 324 | ctx->reg_en); |
325 | if (ret) | ||
326 | return ret; | ||
325 | } | 327 | } |
326 | 328 | ||
327 | ctx->pwm_value = MAX_PWM; | 329 | ctx->pwm_value = MAX_PWM; |
@@ -337,7 +339,9 @@ static int pwm_fan_probe(struct platform_device *pdev) | |||
337 | return ret; | 339 | return ret; |
338 | } | 340 | } |
339 | timer_setup(&ctx->rpm_timer, sample_timer, 0); | 341 | timer_setup(&ctx->rpm_timer, sample_timer, 0); |
340 | devm_add_action_or_reset(dev, pwm_fan_pwm_disable, ctx); | 342 | ret = devm_add_action_or_reset(dev, pwm_fan_pwm_disable, ctx); |
343 | if (ret) | ||
344 | return ret; | ||
341 | 345 | ||
342 | of_property_read_u32(dev->of_node, "pulses-per-revolution", &ppr); | 346 | of_property_read_u32(dev->of_node, "pulses-per-revolution", &ppr); |
343 | ctx->pulses_per_revolution = ppr; | 347 | ctx->pulses_per_revolution = ppr; |