]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
pinctrl: Fix potential memory leak in pinctrl_register_one_pin()
authorSachin Kamat <sachin.kamat@linaro.org>
Tue, 25 Sep 2012 07:11:40 +0000 (12:41 +0530)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 26 Sep 2012 11:15:29 +0000 (13:15 +0200)
'pindesc' was not freed when returning from an error induced
exit path.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/core.c

index dc5c126e398a0ac84fc13fa5f564d832ade0831e..0f1ec9e8ff14b02448877cb4f4872f45baeeccd3 100644 (file)
@@ -230,8 +230,10 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev,
                pindesc->name = name;
        } else {
                pindesc->name = kasprintf(GFP_KERNEL, "PIN%u", number);
-               if (pindesc->name == NULL)
+               if (pindesc->name == NULL) {
+                       kfree(pindesc);
                        return -ENOMEM;
+               }
                pindesc->dynamic_name = true;
        }