diff mbox

pinctrl: bcm2835: Fix memory leak in error path

Message ID 1450658644-20858-1-git-send-email-stefan.wahren@i2se.com
State New
Headers show

Commit Message

Stefan Wahren Dec. 21, 2015, 12:44 a.m. UTC
In case of an invalid pin value bcm2835_pctl_dt_node_to_map()
would leak the pull configs of already assigned pins.
So avoid this by calling the free map function in error case.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Fixes: e1b2dc70cd5b ("pinctrl: add bcm2835 driver")
---
 drivers/pinctrl/bcm/pinctrl-bcm2835.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Anholt Dec. 21, 2015, 10:41 p.m. UTC | #1
Stefan Wahren <stefan.wahren@i2se.com> writes:

> In case of an invalid pin value bcm2835_pctl_dt_node_to_map()
> would leak the pull configs of already assigned pins.
> So avoid this by calling the free map function in error case.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> Fixes: e1b2dc70cd5b ("pinctrl: add bcm2835 driver")

Reviewed-by: Eric Anholt <eric@anholt.net>
Linus Walleij Dec. 22, 2015, 12:51 p.m. UTC | #2
On Mon, Dec 21, 2015 at 1:44 AM, Stefan Wahren <stefan.wahren@i2se.com> wrote:

> In case of an invalid pin value bcm2835_pctl_dt_node_to_map()
> would leak the pull configs of already assigned pins.
> So avoid this by calling the free map function in error case.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> Fixes: e1b2dc70cd5b ("pinctrl: add bcm2835 driver")

Patch applied with Eric's Review tag.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
index 2e6ca69..75b0d8c 100644
--- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
@@ -795,7 +795,7 @@  static int bcm2835_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	return 0;
 
 out:
-	kfree(maps);
+	bcm2835_pctl_dt_free_map(pctldev, maps, num_pins * maps_per_pin);
 	return err;
 }