Skip to contentSkip to conversation

hwmon: (gpio-fan) Check return value from devm_add_action_or_reset

PATCH New Guenter Roeck 1 participant 2 messages Jun 7, 2019 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 1/2 hwmon: (gpio-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 9534784550ab ("hwmon: (gpio-fan) Use devm_thermal_of_cooling_device_register")
---
 drivers/hwmon/gpio-fan.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/gpio-fan.c +3 -1
index 84753680a4e8..54c27e683ee1 100644
@@ -524,7 +524,9 @@ static int gpio_fan_probe(struct platform_device *pdev)
 		err = fan_ctrl_init(fan_data);
 		if (err)
 			return err;
-		devm_add_action_or_reset(dev, gpio_fan_stop, fan_data);
+		err = devm_add_action_or_reset(dev, gpio_fan_stop, fan_data);
+		if (err)
+			return err;
 	}
 
 	/* Make this driver part of hwmon class. */
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH 2/2 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")
---
 drivers/hwmon/pwm-fan.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/hwmon/pwm-fan.c +7 -3
index 08c9b9f1c16e..54c0ff00d67f 100644
@@ -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;
@@ -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;
Signature · 1 line
2.7.4