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.

pinctrl: keembay: release allocated memory in detach path

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>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Bartosz Golaszewski and committed by
Linus Walleij
aae7a287 ea22f777

+5 -2
+5 -2
drivers/pinctrl/pinctrl-keembay.c
··· 1603 1603 * being part of 8 (hw maximum) globally unique muxes. 1604 1604 */ 1605 1605 kpc->nfuncs = 0; 1606 - keembay_funcs = kcalloc(kpc->npins * 8, sizeof(*keembay_funcs), GFP_KERNEL); 1606 + keembay_funcs = devm_kcalloc(kpc->dev, kpc->npins * 8, 1607 + sizeof(*keembay_funcs), GFP_KERNEL); 1607 1608 if (!keembay_funcs) 1608 1609 return -ENOMEM; 1609 1610 ··· 1635 1634 } 1636 1635 1637 1636 /* Reallocate memory based on actual number of functions */ 1638 - new_funcs = krealloc(keembay_funcs, kpc->nfuncs * sizeof(*new_funcs), GFP_KERNEL); 1637 + new_funcs = devm_krealloc_array(kpc->dev, keembay_funcs, 1638 + kpc->nfuncs, sizeof(*new_funcs), 1639 + GFP_KERNEL); 1639 1640 if (!new_funcs) { 1640 1641 kfree(keembay_funcs); 1641 1642 return -ENOMEM;