All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/8] regulator: arizona-micsupp: Avoid potential memory leak reading init_data
@ 2017-03-28 14:14 ` Charles Keepax
  0 siblings, 0 replies; 32+ messages in thread
From: Charles Keepax @ 2017-03-28 14:14 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, lee.jones, robh+dt, mark.rutland, devicetree,
	alsa-devel, linux-kernel, patches

The device argument passed to of_get_regulator_init_data is used to
do some devres memory allocation. Currently the driver passes the MFD
device pointer to this function, this could result in the init_data
allocation being leaked if the regulator is unbound but the MFD isn't.

Correct this issue by correctly passing the local platform device.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---

New patch in the series since v1.

 drivers/regulator/arizona-micsupp.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index 22bd714..5e38861 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -199,7 +199,8 @@ static const struct regulator_init_data arizona_micsupp_ext_default = {
 	.num_consumer_supplies = 1,
 };
 
-static int arizona_micsupp_of_get_pdata(struct arizona *arizona,
+static int arizona_micsupp_of_get_pdata(struct device *dev,
+					struct arizona *arizona,
 					struct regulator_config *config,
 					const struct regulator_desc *desc)
 {
@@ -213,7 +214,7 @@ static int arizona_micsupp_of_get_pdata(struct arizona *arizona,
 	if (np) {
 		config->of_node = np;
 
-		init_data = of_get_regulator_init_data(arizona->dev, np, desc);
+		init_data = of_get_regulator_init_data(dev, np, desc);
 
 		if (init_data) {
 			init_data->consumer_supplies = &micsupp->supply;
@@ -268,8 +269,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
 
 	if (IS_ENABLED(CONFIG_OF)) {
 		if (!dev_get_platdata(arizona->dev)) {
-			ret = arizona_micsupp_of_get_pdata(arizona, &config,
-							   desc);
+			ret = arizona_micsupp_of_get_pdata(&pdev->dev, arizona,
+							   &config, desc);
 			if (ret < 0)
 				return ret;
 		}
-- 
2.1.4

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

end of thread, other threads:[~2017-04-06 18:56 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-28 14:14 [PATCH v2 1/8] regulator: arizona-micsupp: Avoid potential memory leak reading init_data Charles Keepax
2017-03-28 14:14 ` Charles Keepax
2017-03-28 14:14 ` [PATCH v2 2/8] regulator: arizona-ldo1: " Charles Keepax
2017-03-28 14:14   ` Charles Keepax
2017-03-30 21:23   ` Applied "regulator: arizona-ldo1: Avoid potential memory leak reading init_data" to the regulator tree Mark Brown
2017-03-30 21:23     ` Mark Brown
2017-03-28 14:14 ` [PATCH v2 3/8] MAINTAINERS: Add missing regulator regex for Wolfson Arizona parts Charles Keepax
2017-03-28 14:14   ` Charles Keepax
2017-03-30 21:23   ` Applied "MAINTAINERS: Add missing regulator regex for Wolfson Arizona parts" to the regulator tree Mark Brown
2017-03-30 21:23     ` Mark Brown
2017-03-28 14:14 ` [PATCH v2 4/8] regulator: helpers: Add regmap set_soft_start helper Charles Keepax
2017-03-28 14:14   ` Charles Keepax
2017-04-06 18:55   ` Applied "regulator: helpers: Add regmap set_soft_start helper" to the regulator tree Mark Brown
2017-04-06 18:55     ` Mark Brown
2017-03-28 14:14 ` [PATCH v2 5/8] regulator: helpers: Add regmap set_pull_down helper Charles Keepax
2017-03-28 14:14   ` Charles Keepax
2017-04-06 18:55   ` Applied "regulator: helpers: Add regmap set_pull_down helper" to the regulator tree Mark Brown
2017-04-06 18:55     ` Mark Brown
2017-03-28 14:14 ` [PATCH v2 6/8] regulator: arizona-micbias: Add regulator driver for Arizona micbiases Charles Keepax
2017-03-28 14:14   ` Charles Keepax
2017-03-29  6:18   ` [alsa-devel] " kbuild test robot
2017-03-29  6:18     ` kbuild test robot
2017-03-29  8:30     ` Charles Keepax
2017-03-29  8:30       ` Charles Keepax
2017-03-29 10:04   ` [alsa-devel] " kbuild test robot
2017-03-29 10:04     ` kbuild test robot
2017-03-28 14:14 ` [PATCH v2 7/8] regulator: arizona-micbias: Add description of micbias binding Charles Keepax
2017-03-28 14:14   ` Charles Keepax
2017-03-28 14:14 ` [PATCH v2 8/8] ASoC: arizona: Add support for new micbias regulators Charles Keepax
2017-03-28 14:14   ` Charles Keepax
2017-03-30 21:23 ` Applied "regulator: arizona-micsupp: Avoid potential memory leak reading init_data" to the regulator tree Mark Brown
2017-03-30 21:23   ` Mark Brown

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.