From: Pi-Hsun Shih <pihsun@chromium.org>
To: unlisted-recipients:; (no To-header on input)
Cc: Pi-Hsun Shih <pihsun@chromium.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Benson Leung <bleung@chromium.org>,
Enric Balletbo i Serra <enric.balletbo@collabora.com>,
Guenter Roeck <groeck@chromium.org>,
Prashant Malani <pmalani@chromium.org>,
linux-kernel@vger.kernel.org (open list:VOLTAGE AND CURRENT
REGULATOR FRAMEWORK)
Subject: [PATCH] regulator: cros-ec-regulator: Fix double free of desc->name.
Date: Tue, 28 Jul 2020 17:19:09 +0800 [thread overview]
Message-ID: <20200728091909.2009771-1-pihsun@chromium.org> (raw)
The desc->name field is allocated with devm_kstrdup, but is also kfreed
on the error path, causing it to be double freed. Remove the kfree on
the error path.
Fixes: 8d9f8d57e023 ("regulator: Add driver for cros-ec-regulator")
Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
---
drivers/regulator/cros-ec-regulator.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/regulator/cros-ec-regulator.c b/drivers/regulator/cros-ec-regulator.c
index 35f97246bc48..cee259eb0213 100644
--- a/drivers/regulator/cros-ec-regulator.c
+++ b/drivers/regulator/cros-ec-regulator.c
@@ -222,18 +222,13 @@ static int cros_ec_regulator_probe(struct platform_device *pdev)
drvdata->dev = devm_regulator_register(dev, &drvdata->desc, &cfg);
if (IS_ERR(drvdata->dev)) {
- ret = PTR_ERR(drvdata->dev);
dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
- goto free_name;
+ return PTR_ERR(drvdata->dev);
}
platform_set_drvdata(pdev, drvdata);
return 0;
-
-free_name:
- kfree(desc->name);
- return ret;
}
static const struct of_device_id regulator_cros_ec_of_match[] = {
base-commit: 8d9f8d57e023893bfa708d83e3a787e77766a378
--
2.28.0.rc0.142.g3c755180ce-goog
next reply other threads:[~2020-07-28 9:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-28 9:19 Pi-Hsun Shih [this message]
2020-07-28 9:34 ` Enric Balletbo i Serra
2020-07-28 16:31 ` 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=20200728091909.2009771-1-pihsun@chromium.org \
--to=pihsun@chromium.org \
--cc=bleung@chromium.org \
--cc=broonie@kernel.org \
--cc=enric.balletbo@collabora.com \
--cc=groeck@chromium.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pmalani@chromium.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
all inboxes | Powered by JetHome®