[PATCH v1 10/13] regulator: cros-ec: use devm_kmemdup_array()

Raag Jadav
2025-02-21T16:54:32Z

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>
---
drivers/regulator/cros-ec-regulator.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/cros-ec-regulator.c b/drivers/regulator/cros-ec-regulator.c
index fb9643ed7a49..fb0767b33a36 100644
--- a/drivers/regulator/cros-ec-regulator.c
+++ b/drivers/regulator/cros-ec-regulator.c
@@ -138,8 +138,8 @@ static int cros_ec_regulator_init_info(struct device *dev,
data->num_voltages =
min_t(u16, ARRAY_SIZE(resp.voltages_mv), resp.num_voltages);
data->voltages_mV =
- devm_kmemdup(dev, resp.voltages_mv,
- sizeof(u16) * data->num_voltages, GFP_KERNEL);
+ devm_kmemdup_array(dev, resp.voltages_mv, data->num_voltages,
+ sizeof(resp.voltages_mv[0]), GFP_KERNEL);
if (!data->voltages_mV)
return -ENOMEM;

--
2.34.1