linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
To: <broonie@kernel.org>
Cc: <lgirdwood@gmail.com>, <lee.jones@linaro.org>,
	<robh+dt@kernel.org>, <mark.rutland@arm.com>,
	<devicetree@vger.kernel.org>, <alsa-devel@alsa-project.org>,
	<linux-kernel@vger.kernel.org>,
	<patches@opensource.wolfsonmicro.com>
Subject: [PATCH v2 1/8] regulator: arizona-micsupp: Avoid potential memory leak reading init_data
Date: Tue, 28 Mar 2017 15:14:37 +0100	[thread overview]
Message-ID: <1490710484-25277-1-git-send-email-ckeepax@opensource.wolfsonmicro.com> (raw)

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

             reply	other threads:[~2017-03-28 14:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-28 14:14 Charles Keepax [this message]
2017-03-28 14:14 ` [PATCH v2 2/8] regulator: arizona-ldo1: Avoid potential memory leak reading init_data 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-28 14:14 ` [PATCH v2 3/8] MAINTAINERS: Add missing regulator regex for Wolfson Arizona parts 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-28 14:14 ` [PATCH v2 4/8] regulator: helpers: Add regmap set_soft_start helper Charles Keepax
2017-04-06 18:55   ` Applied "regulator: helpers: Add regmap set_soft_start helper" to the regulator tree Mark Brown
2017-03-28 14:14 ` [PATCH v2 5/8] regulator: helpers: Add regmap set_pull_down helper Charles Keepax
2017-04-06 18:55   ` Applied "regulator: helpers: Add regmap set_pull_down helper" to the regulator tree Mark Brown
2017-03-28 14:14 ` [PATCH v2 6/8] regulator: arizona-micbias: Add regulator driver for Arizona micbiases Charles Keepax
2017-03-29  6:18   ` [alsa-devel] " kbuild test robot
2017-03-29  8:30     ` Charles Keepax
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 ` [PATCH v2 8/8] ASoC: arizona: Add support for new micbias regulators Charles Keepax
2017-03-30 21:23 ` Applied "regulator: arizona-micsupp: Avoid potential memory leak reading init_data" to the regulator tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1490710484-25277-1-git-send-email-ckeepax@opensource.wolfsonmicro.com \
    --to=ckeepax@opensource.wolfsonmicro.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).