aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/cros-ec-regulator.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2020-08-02 11:25:09 +0800
committerMark Brown <broonie@kernel.org>2020-08-04 13:24:37 +0100
commitce4109005770ff6f160e1424928b9cc696e8c8f2 (patch)
tree8f8cf28034435c6916d3652c38be928b3d22bdfa /drivers/regulator/cros-ec-regulator.c
parentregulator: add the sub node names for the MP5496 PMIC (diff)
downloadlinux-dev-ce4109005770ff6f160e1424928b9cc696e8c8f2.tar.xz
linux-dev-ce4109005770ff6f160e1424928b9cc696e8c8f2.zip
regulator: cros-ec-regulator: Add NULL test for devm_kmemdup call
Fix possible NULL pointer dereference. Signed-off-by: Axel Lin <axel.lin@ingics.com> Link: https://lore.kernel.org/r/20200802032509.305425-1-axel.lin@ingics.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/cros-ec-regulator.c')
-rw-r--r--drivers/regulator/cros-ec-regulator.c3
1 files changed, 3 insertions, 0 deletions
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 */