Skip to content

Commit d1b35e6

Browse files
Yu JiaoliangTzung-Bi Shih
authored andcommitted
platform/chrome: chromeos_laptop: Use kmemdup_array
Let the kememdup_array() take care about multiplication and possible overflows. Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com> Link: https://lore.kernel.org/r/20240823024056.3031644-1-yujiaoliang@vivo.com Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
1 parent a1927fb commit d1b35e6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/platform/chrome/chromeos_laptop.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -749,10 +749,9 @@ chromeos_laptop_prepare_i2c_peripherals(struct chromeos_laptop *cros_laptop,
749749
if (!src->num_i2c_peripherals)
750750
return 0;
751751

752-
i2c_peripherals = kmemdup(src->i2c_peripherals,
753-
src->num_i2c_peripherals *
754-
sizeof(*src->i2c_peripherals),
755-
GFP_KERNEL);
752+
i2c_peripherals = kmemdup_array(src->i2c_peripherals,
753+
src->num_i2c_peripherals,
754+
sizeof(*i2c_peripherals), GFP_KERNEL);
756755
if (!i2c_peripherals)
757756
return -ENOMEM;
758757

0 commit comments

Comments
 (0)