pinctrl: Fix potential memory leak in pinctrl_register_one_pin()

'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>
This commit is contained in:
Sachin Kamat 2012-09-25 12:41:40 +05:30 committed by Linus Walleij
parent 4c854723c8
commit eb26cc9c71
1 changed files with 3 additions and 1 deletions

View 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;
}