From: Axel Lin <axel.lin@ingics.com>
To: Mark Brown <broonie@kernel.org>
Cc: Pi-Hsun Shih <pihsun@chromium.org>,
Prashant Malani <pmalani@chromium.org>,
Enric Balletbo i Serra <enric.balletbo@collabora.com>,
Liam Girdwood <lgirdwood@gmail.com>,
linux-kernel@vger.kernel.org, Axel Lin <axel.lin@ingics.com>
Subject: [PATCH] regulator: cros-ec-regulator: Add NULL test for devm_kmemdup call
Date: Sun, 2 Aug 2020 11:25:09 +0800 [thread overview]
Message-ID: <20200802032509.305425-1-axel.lin@ingics.com> (raw)
Fix possible NULL pointer dereference.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/regulator/cros-ec-regulator.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/regulator/cros-ec-regulator.c b/drivers/regulator/cros-ec-regulator.c
index 3117bbd2826b..eb3fc1db4edc 100644
--- a/drivers/regulator/cros-ec-regulator.c
+++ b/drivers/regulator/cros-ec-regulator.c
@@ -170,6 +170,9 @@ static int cros_ec_regulator_init_info(struct device *dev,
data->voltages_mV =
devm_kmemdup(dev, resp.voltages_mv,
sizeof(u16) * data->num_voltages, GFP_KERNEL);
+ if (!data->voltages_mV)
+ return -ENOMEM;
+
data->desc.n_voltages = data->num_voltages;
/* Make sure the returned name is always a valid string */
--
2.25.1
next reply other threads:[~2020-08-02 3:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-02 3:25 Axel Lin [this message]
2020-08-03 15:52 ` 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=20200802032509.305425-1-axel.lin@ingics.com \
--to=axel.lin@ingics.com \
--cc=broonie@kernel.org \
--cc=enric.balletbo@collabora.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pihsun@chromium.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®