[PATCH 2/2] regulator: stm32-pwr: release resources to properly support EPROBE_DEFER

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Jul 22 04:09:56 EDT 2020


Driver failed to release resources on failed probe so far, leading to
deferred probe failing with -EBUSY. Fix this.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/regulator/stm32-pwr.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/stm32-pwr.c b/drivers/regulator/stm32-pwr.c
index 296f95bc4c32..99cabc5f8882 100644
--- a/drivers/regulator/stm32-pwr.c
+++ b/drivers/regulator/stm32-pwr.c
@@ -184,18 +184,25 @@ static int stm32_pwr_regulator_probe(struct device_d *dev)
 		priv->rdev.desc = &desc->desc;
 
 		priv->supply = regulator_get(dev, desc->supply_name);
-		if (IS_ERR(priv->supply))
-			return PTR_ERR(priv->supply);
+		if (IS_ERR(priv->supply)) {
+			ret = PTR_ERR(priv->supply);
+			goto release_region;
+		}
 
 		ret = of_regulator_register(&priv->rdev, child);
 		if (ret) {
 			dev_err(dev, "%s: Failed to register regulator: %d\n",
 				desc->name, ret);
-			return ret;
+			goto release_region;
 		}
 	}
 
 	return 0;
+
+release_region:
+	release_region(iores);
+
+	return ret;
 }
 
 static const struct of_device_id stm32_pwr_of_match[] = {
-- 
2.27.0




More information about the barebox mailing list