[PATCH v3 07/15] pinctrl: keembay: release allocated memory in detach path
Andy Shevchenko
andy.shevchenko at gmail.com
Thu Jul 24 04:06:29 PDT 2025
On Thu, Jul 24, 2025 at 11:25 AM Bartosz Golaszewski <brgl at bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bartosz.golaszewski at linaro.org>
>
> Unlike all the other allocations in this driver, the memory for storing
> the pin function descriptions allocated with kcalloc() and later resized
> with krealloc() is never freed. Use devres like elsewhere to handle
> that.
>
> Note: the logic in this module is pretty convoluted and could probably
> use some revisiting, we should probably be able to calculate the exact
> amount of memory needed in advance or even skip the allocation
> alltogether and just add each function to the radix tree separately.
altogether
...
> /* Reallocate memory based on actual number of functions */
> - new_funcs = krealloc(keembay_funcs, kpc->nfuncs * sizeof(*new_funcs), GFP_KERNEL);
> + new_funcs = devm_krealloc(kpc->dev, keembay_funcs,
> + kpc->nfuncs * sizeof(*new_funcs), GFP_KERNEL);
> if (!new_funcs) {
krealloc_array() ?
--
With Best Regards,
Andy Shevchenko
More information about the Linux-mediatek
mailing list