Commit d1b35e6d authored by Yu Jiaoliang's avatar Yu Jiaoliang Committed by Tzung-Bi Shih

platform/chrome: chromeos_laptop: Use kmemdup_array

Let the kememdup_array() take care about multiplication and possible
overflows.
Signed-off-by: default avatarYu Jiaoliang <yujiaoliang@vivo.com>
Link: https://lore.kernel.org/r/20240823024056.3031644-1-yujiaoliang@vivo.comSigned-off-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
parent a1927fbb
......@@ -749,10 +749,9 @@ chromeos_laptop_prepare_i2c_peripherals(struct chromeos_laptop *cros_laptop,
if (!src->num_i2c_peripherals)
return 0;
i2c_peripherals = kmemdup(src->i2c_peripherals,
src->num_i2c_peripherals *
sizeof(*src->i2c_peripherals),
GFP_KERNEL);
i2c_peripherals = kmemdup_array(src->i2c_peripherals,
src->num_i2c_peripherals,
sizeof(*i2c_peripherals), GFP_KERNEL);
if (!i2c_peripherals)
return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment