Skip to content

Commit

Permalink
pinmux: forbid mux_usecount to be set at UINT_MAX
Browse files Browse the repository at this point in the history
If pin_free is called on a pin already freed, mux_usecount is set to
UINT_MAX which is really a bad idea.

This will issue a warning, so that we can correct the code responsible
for the double free.

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Richard Genoud authored and Linus Walleij committed Mar 21, 2013
1 parent 48a23fa commit 740924a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/pinctrl/pinmux.c
Original file line number Diff line number Diff line change
@@ -194,6 +194,11 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
}

if (!gpio_range) {
/*
* A pin should not be freed more times than allocated.
*/
if (WARN_ON(!desc->mux_usecount))
return NULL;
desc->mux_usecount--;
if (desc->mux_usecount)
return NULL;

0 comments on commit 740924a

Please sign in to comment.