]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
pinctrl: sophgo: fix double free in cv1800_pctrl_dt_node_to_map()
authorHarshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Thu, 10 Oct 2024 11:18:18 +0000 (04:18 -0700)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 10 Oct 2024 19:12:59 +0000 (21:12 +0200)
'map' is allocated using devm_* which takes care of freeing the allocated
data, but in error paths there is a call to pinctrl_utils_free_map()
which also does kfree(map) which leads to a double free.

Use kcalloc() instead of devm_kcalloc() as freeing is manually handled.

Fixes: a29d8e93e710 ("pinctrl: sophgo: add support for CV1800B SoC")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Link: https://lore.kernel.org/20241010111830.3474719-1-harshit.m.mogalapalli@oracle.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/sophgo/pinctrl-cv18xx.c

index d18fc5aa84f750e6b1de610baffc6ecc4073ab23..57f2674e75d688c61309ea2f76b0537ce3c530b9 100644 (file)
@@ -221,7 +221,7 @@ static int cv1800_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
        if (!grpnames)
                return -ENOMEM;
 
-       map = devm_kcalloc(dev, ngroups * 2, sizeof(*map), GFP_KERNEL);
+       map = kcalloc(ngroups * 2, sizeof(*map), GFP_KERNEL);
        if (!map)
                return -ENOMEM;