* [PATCH v2] gpio: wcd934x: Fix shift-out-of-bounds error
@ 2021-03-10 17:43 Srinivas Kandagatla
2021-03-10 23:32 ` Bjorn Andersson
2021-05-04 12:37 ` Srinivas Kandagatla
0 siblings, 2 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2021-03-10 17:43 UTC (permalink / raw)
To: linus.walleij, linux-gpio
Cc: linux-kernel, john.stultz, amit.pundir, bjorn.andersson,
Srinivas Kandagatla, Andy Shevchenko
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>
---
changes since v1:
- removed unnecessary dump stack from log
drivers/gpio/gpio-wcd934x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-wcd934x.c b/drivers/gpio/gpio-wcd934x.c
index 1cbce5990855..97e6caedf1f3 100644
--- a/drivers/gpio/gpio-wcd934x.c
+++ b/drivers/gpio/gpio-wcd934x.c
@@ -7,7 +7,7 @@
#include <linux/slab.h>
#include <linux/of_device.h>
-#define WCD_PIN_MASK(p) BIT(p - 1)
+#define WCD_PIN_MASK(p) BIT(p)
#define WCD_REG_DIR_CTL_OFFSET 0x42
#define WCD_REG_VAL_CTL_OFFSET 0x43
#define WCD934X_NPINS 5
--
2.21.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] gpio: wcd934x: Fix shift-out-of-bounds error
2021-03-10 17:43 [PATCH v2] gpio: wcd934x: Fix shift-out-of-bounds error Srinivas Kandagatla
@ 2021-03-10 23:32 ` Bjorn Andersson
2021-05-04 12:37 ` Srinivas Kandagatla
1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2021-03-10 23:32 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: linus.walleij, linux-gpio, linux-kernel, john.stultz,
amit.pundir, Andy Shevchenko
On Wed 10 Mar 11:43 CST 2021, Srinivas Kandagatla wrote:
> 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>
Regards,
Bjorn
> ---
> changes since v1:
> - removed unnecessary dump stack from log
>
> drivers/gpio/gpio-wcd934x.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-wcd934x.c b/drivers/gpio/gpio-wcd934x.c
> index 1cbce5990855..97e6caedf1f3 100644
> --- a/drivers/gpio/gpio-wcd934x.c
> +++ b/drivers/gpio/gpio-wcd934x.c
> @@ -7,7 +7,7 @@
> #include <linux/slab.h>
> #include <linux/of_device.h>
>
> -#define WCD_PIN_MASK(p) BIT(p - 1)
> +#define WCD_PIN_MASK(p) BIT(p)
> #define WCD_REG_DIR_CTL_OFFSET 0x42
> #define WCD_REG_VAL_CTL_OFFSET 0x43
> #define WCD934X_NPINS 5
> --
> 2.21.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] gpio: wcd934x: Fix shift-out-of-bounds error
2021-03-10 17:43 [PATCH v2] gpio: wcd934x: Fix shift-out-of-bounds error Srinivas Kandagatla
2021-03-10 23:32 ` Bjorn Andersson
@ 2021-05-04 12:37 ` Srinivas Kandagatla
1 sibling, 0 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2021-05-04 12:37 UTC (permalink / raw)
To: linus.walleij, linux-gpio
Cc: linux-kernel, john.stultz, amit.pundir, bjorn.andersson, Andy Shevchenko
Hi Linus,
On 10/03/2021 17:43, Srinivas Kandagatla wrote:
> 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>
> ---
Looks like this patch was missed. Without this audio on DragonBoard
DB845c is broken once rc1 is out, as the corresponding dts changes are
already in next.
Any chance to get this in .. maybe after rc1?
--srini
> changes since v1:
> - removed unnecessary dump stack from log
>
> drivers/gpio/gpio-wcd934x.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-wcd934x.c b/drivers/gpio/gpio-wcd934x.c
> index 1cbce5990855..97e6caedf1f3 100644
> --- a/drivers/gpio/gpio-wcd934x.c
> +++ b/drivers/gpio/gpio-wcd934x.c
> @@ -7,7 +7,7 @@
> #include <linux/slab.h>
> #include <linux/of_device.h>
>
> -#define WCD_PIN_MASK(p) BIT(p - 1)
> +#define WCD_PIN_MASK(p) BIT(p)
> #define WCD_REG_DIR_CTL_OFFSET 0x42
> #define WCD_REG_VAL_CTL_OFFSET 0x43
> #define WCD934X_NPINS 5
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-04 12:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 17:43 [PATCH v2] gpio: wcd934x: Fix shift-out-of-bounds error Srinivas Kandagatla
2021-03-10 23:32 ` Bjorn Andersson
2021-05-04 12:37 ` Srinivas Kandagatla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).