]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
pinctrl: single: Add missing free in single_allocate_function
authorFrancois Berder <fberder@outlook.fr>
Tue, 2 Dec 2025 18:39:39 +0000 (19:39 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 16 Dec 2025 17:36:41 +0000 (11:36 -0600)
If func->pins could not be allocated, one must also free
func variable that was allocated previously.

Signed-off-by: Francois Berder <fberder@outlook.fr>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
drivers/pinctrl/pinctrl-single.c

index c96b293aadf4126cb3b5641676bba736e34326ab..42980e097e0def158ab8d6779cb18a57a2fdb23c 100644 (file)
@@ -282,8 +282,10 @@ static struct single_func *single_allocate_function(struct udevice *dev,
 
        func->pins = devm_kmalloc(dev, sizeof(unsigned int) * group_pins,
                                  GFP_KERNEL);
-       if (!func->pins)
+       if (!func->pins) {
+               devm_kfree(dev, func);
                return ERR_PTR(-ENOMEM);
+       }
 
        return func;
 }