diff options
author | Axel Lin <axel.lin@ingics.com> | 2020-08-02 06:25:09 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-08-04 15:24:37 +0300 |
commit | ce4109005770ff6f160e1424928b9cc696e8c8f2 (patch) | |
tree | 8f8cf28034435c6916d3652c38be928b3d22bdfa /drivers/regulator/cros-ec-regulator.c | |
parent | bcb3b2a7639db2412875520cddc3abd179068793 (diff) | |
download | linux-ce4109005770ff6f160e1424928b9cc696e8c8f2.tar.xz |
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.c | 3 |
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 */ |