From: Richard Genoud Date: Thu, 21 Mar 2013 11:21:47 +0000 (+0100) Subject: pinmux: forbid mux_usecount to be set at UINT_MAX X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=740924a267e85de09707ea158bbf594b4d8bae01;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git pinmux: forbid mux_usecount to be set at UINT_MAX 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 Reviewed-by: Stephen Warren Signed-off-by: Linus Walleij --- diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index 1a00658b3ea0..bd83c8b01cd1 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -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;