[PATCH 2/5] iio: adc: xilinx: use devm_krealloc() instead of kfree() + kcalloc()
Andy Shevchenko
andy.shevchenko at gmail.com
Tue Oct 27 05:33:17 EDT 2020
On Mon, Oct 26, 2020 at 4:03 PM Bartosz Golaszewski <brgl at bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bgolaszewski at baylibre.com>
>
> We now have devm_krealloc() in the kernel Use it indstead of calling
> kfree() and kcalloc() separately.
Which is completely lawful when size > previous_size (I mean, the
additional patch you sent previously seems not related to this).
> - kfree(xadc->data);
> - xadc->data = kcalloc(n, sizeof(*xadc->data), GFP_KERNEL);
> + xadc->data = devm_krealloc(indio_dev->dev.parent, xadc->data,
> + n * sizeof(*xadc->data),
I think you need to use something from overflow.h instead of explicit
multiplication here.
> + GFP_KERNEL | __GFP_ZERO);
--
With Best Regards,
Andy Shevchenko
More information about the linux-arm-kernel
mailing list