From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
John Stultz <john.stultz@linaro.org>,
amit.pundir@linaro.org,
Bjorn Andersson <bjorn.andersson@linaro.org>
Subject: Re: [PATCH] gpio: wcd934x: Fix shift-out-of-bounds error
Date: Tue, 9 Mar 2021 16:42:35 +0000 [thread overview]
Message-ID: <aa21e433-b1ee-44ee-8c1b-bfb2e9a04bb5@linaro.org> (raw)
In-Reply-To: <CAHp75VcBc_pYVPw6A4tH0fqzWKtCT61a45tfN9ZrhuLee1VBUg@mail.gmail.com>
On 09/03/2021 16:31, Andy Shevchenko wrote:
> On Tue, Mar 9, 2021 at 12:21 PM Srinivas Kandagatla
> <srinivas.kandagatla@linaro.org> 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
>
> It would be nice to reduce below to ~2-3 (significant) lines.
I agree! Will do that in next version!
--srini
>
>> UBSAN: shift-out-of-bounds in /workspace/dev/linux/drivers/gpio/gpio-wcd934x.c:34:14
>> qcom-q6v5-mss 4080000.remoteproc: failed to acquire pdc reset
>> remoteproc remoteproc2: releasing 4080000.remoteproc
>> shift exponent 4294967295 is too large for 64-bit type 'long unsigned int'
>> CPU: 6 PID: 155 Comm: kworker/6:2 Not tainted 5.12.0-rc1-00045-g508b7280ec3d-dirty #1396
>> Hardware name: Thundercomm Dragonboard 845c (DT)
>>
>> Call trace:
>> dump_backtrace+0x0/0x1c0
>> show_stack+0x18/0x68
>> dump_stack+0xd8/0x134
>> ubsan_epilogue+0x10/0x58
>> __ubsan_handle_shift_out_of_bounds+0xf8/0x168
>> wcd_gpio_get_direction+0xc8/0xd8
>> gpiochip_add_data_with_key+0x4ac/0xe78
>> devm_gpiochip_add_data_with_key+0x30/0x90
>> wcd_gpio_probe+0xc8/0x118
>> platform_probe+0x6c/0x118
>> really_probe+0x24c/0x418
>> driver_probe_device+0x68/0xf0
>> __device_attach_driver+0xb4/0x110
>
> After addressing above, FWIW,
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
>> Fixes: 59c324683400 ("gpio: wcd934x: Add support to wcd934x gpio controller")
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> ---
>> 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
>>
>
>
prev parent reply other threads:[~2021-03-09 16:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-09 10:19 [PATCH] gpio: wcd934x: Fix shift-out-of-bounds error Srinivas Kandagatla
2021-03-09 16:31 ` Andy Shevchenko
2021-03-09 16:42 ` Srinivas Kandagatla [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aa21e433-b1ee-44ee-8c1b-bfb2e9a04bb5@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=amit.pundir@linaro.org \
--cc=andy.shevchenko@gmail.com \
--cc=bjorn.andersson@linaro.org \
--cc=john.stultz@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).