aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>2025-09-02 13:59:17 +0200
committerLinus Walleij <linus.walleij@linaro.org>2025-09-03 00:12:24 +0200
commit995bc9f4826e8e4ccf4029eec8f7ecb238202287 (patch)
tree7f21a79c26e07477cbd040fad36b7d4bf9871af8
parent9108fa17310ba4fd3a53d2fe88944bd3e99402b3 (diff)
downloadnet-995bc9f4826e.tar.gz
pinctrl: keembay: release allocated memory in detach path
Notice: this object is not reachable from any branch.
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. While at it - replace krealloc() with more suitable devm_krealloc_array(). 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 altogether and just add each function to the radix tree separately. Tested-by: Neil Armstrong <neil.armstrong@linaro.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Link: https://lore.kernel.org/20250902-pinctrl-gpio-pinfuncs-v7-8-bb091daedc52@linaro.org Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Notice: this object is not reachable from any branch.
-rw-r--r--drivers/pinctrl/pinctrl-keembay.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/pinctrl/pinctrl-keembay.c b/drivers/pinctrl/pinctrl-keembay.c
index 60cf017498b32a..6aefcbc3130999 100644
--- a/drivers/pinctrl/pinctrl-keembay.c
+++ b/drivers/pinctrl/pinctrl-keembay.c
@@ -1603,7 +1603,8 @@ static int keembay_build_functions(struct keembay_pinctrl *kpc)
* being part of 8 (hw maximum) globally unique muxes.
*/
kpc->nfuncs = 0;
- keembay_funcs = kcalloc(kpc->npins * 8, sizeof(*keembay_funcs), GFP_KERNEL);
+ keembay_funcs = devm_kcalloc(kpc->dev, kpc->npins * 8,
+ sizeof(*keembay_funcs), GFP_KERNEL);
if (!keembay_funcs)
return -ENOMEM;
@@ -1634,7 +1635,9 @@ static int keembay_build_functions(struct keembay_pinctrl *kpc)
}
/* Reallocate memory based on actual number of functions */
- new_funcs = krealloc(keembay_funcs, kpc->nfuncs * sizeof(*new_funcs), GFP_KERNEL);
+ new_funcs = devm_krealloc_array(kpc->dev, keembay_funcs,
+ kpc->nfuncs, sizeof(*new_funcs),
+ GFP_KERNEL);
if (!new_funcs) {
kfree(keembay_funcs);
return -ENOMEM;