[lkml]   [2018]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectApplied "regulator: gpio: Fix some error handling paths in 'gpio_regulator_probe()'" to the regulator tree
The patch

regulator: gpio: Fix some error handling paths in 'gpio_regulator_probe()'

has been applied to the regulator tree at

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.


From ed8cffda27dea6fd3dafb3ee881c5a786edac9ca Mon Sep 17 00:00:00 2001
From: Christophe Jaillet <>
Date: Tue, 13 Mar 2018 21:33:11 +0100
Subject: [PATCH] regulator: gpio: Fix some error handling paths in

Re-order error handling code and gotos to avoid leaks in error handling

Fixes: 9f946099fe19 ("regulator: gpio: fix parsing of gpio list")
Signed-off-by: Christophe JAILLET <>
Signed-off-by: Mark Brown <>
drivers/regulator/gpio-regulator.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 0fce06acfaec..a2eb50719c7b 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -271,8 +271,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)
drvdata-> = kstrdup(config->supply_name, GFP_KERNEL);
if (drvdata-> == NULL) {
dev_err(&pdev->dev, "Failed to allocate supply name\n");
- ret = -ENOMEM;
- goto err;
+ return -ENOMEM;

if (config->nr_gpios != 0) {
@@ -292,7 +291,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)
"Could not obtain regulator setting GPIOs: %d\n",
- goto err_memstate;
+ goto err_memgpio;

@@ -303,7 +302,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)
if (drvdata->states == NULL) {
dev_err(&pdev->dev, "Failed to allocate state data\n");
ret = -ENOMEM;
- goto err_memgpio;
+ goto err_stategpio;
drvdata->nr_states = config->nr_states;

@@ -324,7 +323,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "No regulator type set\n");
ret = -EINVAL;
- goto err_memgpio;
+ goto err_memstate;

/* build initial state from gpio init data. */
@@ -361,22 +360,21 @@ static int gpio_regulator_probe(struct platform_device *pdev)
if (IS_ERR(drvdata->dev)) {
ret = PTR_ERR(drvdata->dev);
dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
- goto err_stategpio;
+ goto err_memstate;

platform_set_drvdata(pdev, drvdata);

return 0;

- gpio_free_array(drvdata->gpios, drvdata->nr_gpios);
+ gpio_free_array(drvdata->gpios, drvdata->nr_gpios);
return ret;

 \ /
  Last update: 2018-03-14 17:40    [W:0.032 / U:3.576 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site