Skip to content
Snippets Groups Projects
Unverified Commit ce410900 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown
Browse files

regulator: cros-ec-regulator: Add NULL test for devm_kmemdup call


Fix possible NULL pointer dereference.

Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Link: https://lore.kernel.org/r/20200802032509.305425-1-axel.lin@ingics.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent bcb3b2a7
No related branches found
No related tags found
No related merge requests found
......@@ -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 */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment