All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] regulator: Fix memory leak in set_machine_constraints() error paths
@ 2011-07-15  2:50 Axel Lin
  2011-07-15  4:36 ` Mark Brown
  2011-07-22 10:47 ` Liam Girdwood
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2011-07-15  2:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown

Properly kfree rdev->constraints in all set_machine_constraints() error paths.
Also properly kfree rdev->constraints in regulator_register() error paths.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/core.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index f59821f..44a45bd 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -787,7 +787,6 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
 		if (ret < 0) {
 			rdev_err(rdev, "failed to apply %duV constraint\n",
 				 rdev->constraints->min_uV);
-			rdev->constraints = NULL;
 			return ret;
 		}
 	}
@@ -890,7 +889,6 @@ static int set_machine_constraints(struct regulator_dev *rdev,
 		ret = suspend_prepare(rdev, rdev->constraints->initial_state);
 		if (ret < 0) {
 			rdev_err(rdev, "failed to set suspend state\n");
-			rdev->constraints = NULL;
 			goto out;
 		}
 	}
@@ -917,13 +915,15 @@ static int set_machine_constraints(struct regulator_dev *rdev,
 		ret = ops->enable(rdev);
 		if (ret < 0) {
 			rdev_err(rdev, "failed to enable\n");
-			rdev->constraints = NULL;
 			goto out;
 		}
 	}
 
 	print_constraints(rdev);
+	return 0;
 out:
+	kfree(rdev->constraints);
+	rdev->constraints = NULL;
 	return ret;
 }
 
@@ -2694,6 +2694,7 @@ unset_supplies:
 	unset_regulator_supplies(rdev);
 
 scrub:
+	kfree(rdev->constraints);
 	device_unregister(&rdev->dev);
 	/* device core frees rdev */
 	rdev = ERR_PTR(ret);
-- 
1.7.4.1




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] regulator: Fix memory leak in set_machine_constraints() error paths
  2011-07-15  2:50 [PATCH v3] regulator: Fix memory leak in set_machine_constraints() error paths Axel Lin
@ 2011-07-15  4:36 ` Mark Brown
  2011-07-22 10:47 ` Liam Girdwood
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2011-07-15  4:36 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Liam Girdwood

On Fri, Jul 15, 2011 at 10:50:43AM +0800, Axel Lin wrote:
> Properly kfree rdev->constraints in all set_machine_constraints() error paths.
> Also properly kfree rdev->constraints in regulator_register() error paths.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] regulator: Fix memory leak in set_machine_constraints() error paths
  2011-07-15  2:50 [PATCH v3] regulator: Fix memory leak in set_machine_constraints() error paths Axel Lin
  2011-07-15  4:36 ` Mark Brown
@ 2011-07-22 10:47 ` Liam Girdwood
  1 sibling, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2011-07-22 10:47 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, Mark Brown

On Fri, 2011-07-15 at 10:50 +0800, Axel Lin wrote:
> Properly kfree rdev->constraints in all set_machine_constraints() error paths.
> Also properly kfree rdev->constraints in regulator_register() error paths.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied.

Thanks

Liam


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-07-22 10:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-15  2:50 [PATCH v3] regulator: Fix memory leak in set_machine_constraints() error paths Axel Lin
2011-07-15  4:36 ` Mark Brown
2011-07-22 10:47 ` Liam Girdwood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.