mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
bcb3b2a763
commit
ce41090057
|
@ -170,6 +170,9 @@ static int cros_ec_regulator_init_info(struct device *dev,
|
||||||
data->voltages_mV =
|
data->voltages_mV =
|
||||||
devm_kmemdup(dev, resp.voltages_mv,
|
devm_kmemdup(dev, resp.voltages_mv,
|
||||||
sizeof(u16) * data->num_voltages, GFP_KERNEL);
|
sizeof(u16) * data->num_voltages, GFP_KERNEL);
|
||||||
|
if (!data->voltages_mV)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
data->desc.n_voltages = data->num_voltages;
|
data->desc.n_voltages = data->num_voltages;
|
||||||
|
|
||||||
/* Make sure the returned name is always a valid string */
|
/* Make sure the returned name is always a valid string */
|
||||||
|
|
Loading…
Reference in New Issue