summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Jiaoliang <yujiaoliang@vivo.com>2024-08-23 05:40:56 +0300
committerTzung-Bi Shih <tzungbi@kernel.org>2024-08-23 16:48:43 +0300
commitd1b35e6d34e9b46fbf98444dd7aa114c032e9ac0 (patch)
tree0f717b732f53edf3116f3fd8d3b67e77f1710521
parenta1927fbbf74f9f61eb5c6d1414037c97a8d942ab (diff)
downloadlinux-d1b35e6d34e9b46fbf98444dd7aa114c032e9ac0.tar.xz
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>
-rw-r--r--drivers/platform/chrome/chromeos_laptop.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c
index a2cdbfbaeae6..3ab668764383 100644
--- a/drivers/platform/chrome/chromeos_laptop.c
+++ b/drivers/platform/chrome/chromeos_laptop.c
@@ -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;