From: Phil Reid Date: Tue, 8 Nov 2016 06:00:45 +0000 (+0800) Subject: gpio: pca953x: Fix corruption of other gpios in set_multiple. X-Git-Tag: v4.8.11~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9a0027757f8c317f1d7334c095bde96b4a0f84c;p=thirdparty%2Fkernel%2Fstable.git gpio: pca953x: Fix corruption of other gpios in set_multiple. commit 53f8d322234649b4d6f1515b20c127a577efd164 upstream. gpiod_set_array_value_complex does not clear the bits field. Therefore when the drivers set_multiple funciton is called bits outside the mask are undefined and can be either set or not. So bank_val needs to be masked with bank_mask before or with the reg_val cache. Fixes: b4818afeacbd ("gpio: pca953x: Add set_multiple to allow multiple") Signed-off-by: Phil Reid Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 5fae629c241e6..47d08b9da60d1 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -380,6 +380,7 @@ static void pca953x_gpio_set_multiple(struct gpio_chip *gc, if(bankmask) { unsigned bankval = bits[bank / sizeof(*bits)] >> ((bank % sizeof(*bits)) * 8); + bankval &= bankmask; reg_val[bank] = (reg_val[bank] & ~bankmask) | bankval; } }