Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: wcd934x: Fix shift-out-of-bounds error

bit-mask for pins 0 to 4 is BIT(0) to BIT(4) however we ended up with BIT(n - 1)
which is not right, and this was caught by below usban check

UBSAN: shift-out-of-bounds in drivers/gpio/gpio-wcd934x.c:34:14

Fixes: 59c324683400 ("gpio: wcd934x: Add support to wcd934x gpio controller")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

authored by

Srinivas Kandagatla and committed by
Bartosz Golaszewski
dbec64b1 bdbe871e

+1 -1
+1 -1
drivers/gpio/gpio-wcd934x.c
··· 7 7 #include <linux/slab.h> 8 8 #include <linux/of_device.h> 9 9 10 - #define WCD_PIN_MASK(p) BIT(p - 1) 10 + #define WCD_PIN_MASK(p) BIT(p) 11 11 #define WCD_REG_DIR_CTL_OFFSET 0x42 12 12 #define WCD_REG_VAL_CTL_OFFSET 0x43 13 13 #define WCD934X_NPINS 5