From: Andy Shevchenko Date: Mon, 24 Jul 2023 11:02:03 +0000 (+0300) Subject: iio: core: Switch to krealloc_array() X-Git-Tag: v6.6.7~2016^2~44^2~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a0821e0e369b7c1d65bd10251fe42c7a55d74d5;p=platform%2Fkernel%2Flinux-starfive.git iio: core: Switch to krealloc_array() Let the krealloc_array() copy the original data and check for a multiplication overflow. Signed-off-by: Andy Shevchenko Reviewed-by: Nuno Sa Link: https://lore.kernel.org/r/20230724110204.46285-4-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 895b89a..75e4f31 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1474,7 +1474,7 @@ int iio_device_register_sysfs_group(struct iio_dev *indio_dev, const struct attribute_group **new, **old = iio_dev_opaque->groups; unsigned int cnt = iio_dev_opaque->groupcounter; - new = krealloc(old, sizeof(*new) * (cnt + 2), GFP_KERNEL); + new = krealloc_array(old, cnt + 2, sizeof(*new), GFP_KERNEL); if (!new) return -ENOMEM;