summaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2023-07-24 14:02:03 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2023-07-29 12:47:28 +0100
commit5a0821e0e369b7c1d65bd10251fe42c7a55d74d5 (patch)
tree22602959dc6c5ab96af6166d45f34df2af999222 /drivers/iio
parent971ddd4b4db605191fed2b1d13612f3bbf3195b3 (diff)
downloadlinux-stable-5a0821e0e369b7c1d65bd10251fe42c7a55d74d5.tar.gz
linux-stable-5a0821e0e369b7c1d65bd10251fe42c7a55d74d5.tar.bz2
linux-stable-5a0821e0e369b7c1d65bd10251fe42c7a55d74d5.zip
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 <andriy.shevchenko@linux.intel.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20230724110204.46285-4-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/industrialio-core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 895b89a8c785..75e4f31c6dd6 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;