From 9b77ace409e1419c331209c4c8eb2c8bc990e9fd Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 19 Aug 2013 10:07:46 +0800 Subject: [PATCH] pinctrl: core: Add proper mutex lock in pinctrl_request_gpio This one is missed in commit 42fed7ba "pinctrl: move subsystem mutex to pinctrl_dev struct". I think this fixes the race between pin_free() and pin_request() calls. It protects accessing the members of pctldev->desc. (e.g. update desc->mux_usecount, desc->gpio_owner, desc->mux_owner, etc) Current code grabs pctldev->mutex before calling pinmux_free_gpio(), but did not grab the mutex while calling pinmux_request_gpio(). Signed-off-by: Axel Lin Signed-off-by: Linus Walleij --- drivers/pinctrl/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 7094a8129008..054d14b43db4 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -562,11 +562,15 @@ int pinctrl_request_gpio(unsigned gpio) return ret; } + mutex_lock(&pctldev->mutex); + /* Convert to the pin controllers number space */ pin = gpio_to_pin(range, gpio); ret = pinmux_request_gpio(pctldev, range, pin, gpio); + mutex_unlock(&pctldev->mutex); + return ret; } EXPORT_SYMBOL_GPL(pinctrl_request_gpio); -- 2.39.5