From: Krzysztof Kozlowski <krzk@kernel.org>
To: Sangbeom Kim <sbkim73@samsung.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org
Cc: Georg Waibel <georg.waibel@sensor-technik.de>,
Marek Szyprowski <m.szyprowski@samsung.com>,
stable@vger.kernel.org
Subject: [PATCH] regulator: s2mps11: Fix ERR_PTR dereference on GPIO lookup failure
Date: Wed, 19 Jun 2019 14:42:39 +0200 [thread overview]
Message-ID: <1560948159-21926-1-git-send-email-krzk@kernel.org> (raw)
If devm_gpiod_get_from_of_node() call returns ERR_PTR, it is assigned
into an array of GPIO descriptors and used later because such error is
not treated as critical thus it is not propagated back to the probe
function.
All code later expects that such GPIO descriptor is either a NULL or
proper value. This later might lead to dereference of ERR_PTR.
Only devices with S2MPS14 flavor are affected (other do not control
regulators with GPIOs).
Fixes: 1c984942f0a4 ("regulator: s2mps11: Pass descriptor instead of GPIO number")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
The exact error condition was not tested because I do not have board
with S2MPS14.
---
drivers/regulator/s2mps11.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 134c62db36c5..af9bf10b4c33 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -824,6 +824,7 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev,
if (IS_ERR(gpio[reg])) {
dev_err(&pdev->dev, "Failed to get control GPIO for %d/%s\n",
reg, rdata[reg].name);
+ gpio[reg] = NULL;
continue;
}
if (gpio[reg])
--
2.7.4
next reply other threads:[~2019-06-19 12:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-19 12:42 Krzysztof Kozlowski [this message]
2019-06-20 13:32 ` Applied "regulator: s2mps11: Fix ERR_PTR dereference on GPIO lookup failure" to the regulator tree Mark Brown
2019-06-20 13:32 ` Mark Brown
[not found] ` <20190622181347.3BFC52070B@mail.kernel.org>
2019-06-24 7:01 ` [PATCH] regulator: s2mps11: Fix ERR_PTR dereference on GPIO lookup failure Krzysztof Kozlowski
2019-06-24 10:11 ` Sasha Levin
2019-06-24 10:41 ` Krzysztof Kozlowski
2019-06-24 10:47 ` Krzysztof Kozlowski
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=1560948159-21926-1-git-send-email-krzk@kernel.org \
--to=krzk@kernel.org \
--cc=b.zolnierkie@samsung.com \
--cc=broonie@kernel.org \
--cc=georg.waibel@sensor-technik.de \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=sbkim73@samsung.com \
--cc=stable@vger.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 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.