regulator: cros-ec: use devm_kmemdup_array()
Convert to use devm_kmemdup_array() and while at it, make the size robust against type changes. Signed-off-by: Raag Jadav <raag.jadav@intel.com> Link: https://patch.msgid.link/20250228072057.151436-3-raag.jadav@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>pull/1184/head
parent
6ddd115982
commit
c5c4ce6612
|
|
@ -138,8 +138,8 @@ static int cros_ec_regulator_init_info(struct device *dev,
|
||||||
data->num_voltages =
|
data->num_voltages =
|
||||||
min_t(u16, ARRAY_SIZE(resp.voltages_mv), resp.num_voltages);
|
min_t(u16, ARRAY_SIZE(resp.voltages_mv), resp.num_voltages);
|
||||||
data->voltages_mV =
|
data->voltages_mV =
|
||||||
devm_kmemdup(dev, resp.voltages_mv,
|
devm_kmemdup_array(dev, resp.voltages_mv, data->num_voltages,
|
||||||
sizeof(u16) * data->num_voltages, GFP_KERNEL);
|
sizeof(resp.voltages_mv[0]), GFP_KERNEL);
|
||||||
if (!data->voltages_mV)
|
if (!data->voltages_mV)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue