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
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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 */