Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Andy Shevchenko and committed by
Jonathan Cameron
5a0821e0 971ddd4b

+1 -1
+1 -1
drivers/iio/industrialio-core.c
··· 1474 1474 const struct attribute_group **new, **old = iio_dev_opaque->groups; 1475 1475 unsigned int cnt = iio_dev_opaque->groupcounter; 1476 1476 1477 - new = krealloc(old, sizeof(*new) * (cnt + 2), GFP_KERNEL); 1477 + new = krealloc_array(old, cnt + 2, sizeof(*new), GFP_KERNEL); 1478 1478 if (!new) 1479 1479 return -ENOMEM; 1480 1480