Skip to content

Commit ce41090

Browse files
AxelLinbroonie
authored andcommitted
regulator: cros-ec-regulator: Add NULL test for devm_kmemdup call
Fix possible NULL pointer dereference. Signed-off-by: Axel Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent bcb3b2a commit ce41090

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/regulator/cros-ec-regulator.c

+3
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ static int cros_ec_regulator_init_info(struct device *dev,
170170
data->voltages_mV =
171171
devm_kmemdup(dev, resp.voltages_mv,
172172
sizeof(u16) * data->num_voltages, GFP_KERNEL);
173+
if (!data->voltages_mV)
174+
return -ENOMEM;
175+
173176
data->desc.n_voltages = data->num_voltages;
174177

175178
/* Make sure the returned name is always a valid string */

0 commit comments

Comments
 (0)