* [PATCH] mfd: stmfx: Fix an endian bug in stmfx_irq_handler()
[not found] <CAHk-=wgTL5sYCGxX8+xQqyBRWRUE05GAdL58+UTG8bYwjFxMkw@mail.gmail.com>
@ 2019-06-17 19:06 ` Dan Carpenter
2019-06-18 8:16 ` Lee Jones
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-06-17 19:06 UTC (permalink / raw)
To: Lee Jones, Linus Torvalds
Cc: Amelie Delaunay, Alexandre Torgue, kernel-janitors,
Linux List Kernel Mailing, Maxime Coquelin, linux-stm32,
linux-arm-kernel
It's not okay to cast a "u32 *" to "unsigned long *" when you are
doing a for_each_set_bit() loop because that will break on big
endian systems.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Fixes: 386145601b82 ("mfd: stmfx: Uninitialized variable in stmfx_irq_handler()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/mfd/stmfx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/mfd/stmfx.c b/drivers/mfd/stmfx.c
index 7c419c078688..857991cb3cbb 100644
--- a/drivers/mfd/stmfx.c
+++ b/drivers/mfd/stmfx.c
@@ -204,6 +204,7 @@ static struct irq_chip stmfx_irq_chip = {
static irqreturn_t stmfx_irq_handler(int irq, void *data)
{
struct stmfx *stmfx = data;
+ unsigned long bits;
u32 pending, ack;
int n, ret;
@@ -222,7 +223,8 @@ static irqreturn_t stmfx_irq_handler(int irq, void *data)
return IRQ_NONE;
}
- for_each_set_bit(n, (unsigned long *)&pending, STMFX_REG_IRQ_SRC_MAX)
+ bits = pending;
+ for_each_set_bit(n, &bits, STMFX_REG_IRQ_SRC_MAX)
handle_nested_irq(irq_find_mapping(stmfx->irq_domain, n));
return IRQ_HANDLED;
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mfd: stmfx: Fix an endian bug in stmfx_irq_handler()
2019-06-17 19:06 ` [PATCH] mfd: stmfx: Fix an endian bug in stmfx_irq_handler() Dan Carpenter
@ 2019-06-18 8:16 ` Lee Jones
2019-06-18 20:55 ` Linus Torvalds
0 siblings, 1 reply; 5+ messages in thread
From: Lee Jones @ 2019-06-18 8:16 UTC (permalink / raw)
To: Dan Carpenter
Cc: Amelie Delaunay, Alexandre Torgue, kernel-janitors,
Linux List Kernel Mailing, Maxime Coquelin, Linus Torvalds,
linux-stm32, linux-arm-kernel
On Mon, 17 Jun 2019, Dan Carpenter wrote:
> It's not okay to cast a "u32 *" to "unsigned long *" when you are
> doing a for_each_set_bit() loop because that will break on big
> endian systems.
>
> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Ideally we can get a review too.
> Fixes: 386145601b82 ("mfd: stmfx: Uninitialized variable in stmfx_irq_handler()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/mfd/stmfx.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/stmfx.c b/drivers/mfd/stmfx.c
> index 7c419c078688..857991cb3cbb 100644
> --- a/drivers/mfd/stmfx.c
> +++ b/drivers/mfd/stmfx.c
> @@ -204,6 +204,7 @@ static struct irq_chip stmfx_irq_chip = {
> static irqreturn_t stmfx_irq_handler(int irq, void *data)
> {
> struct stmfx *stmfx = data;
> + unsigned long bits;
> u32 pending, ack;
> int n, ret;
>
> @@ -222,7 +223,8 @@ static irqreturn_t stmfx_irq_handler(int irq, void *data)
> return IRQ_NONE;
> }
>
> - for_each_set_bit(n, (unsigned long *)&pending, STMFX_REG_IRQ_SRC_MAX)
> + bits = pending;
> + for_each_set_bit(n, &bits, STMFX_REG_IRQ_SRC_MAX)
> handle_nested_irq(irq_find_mapping(stmfx->irq_domain, n));
>
> return IRQ_HANDLED;
--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mfd: stmfx: Fix an endian bug in stmfx_irq_handler()
2019-06-18 8:16 ` Lee Jones
@ 2019-06-18 20:55 ` Linus Torvalds
2019-06-19 5:58 ` Lee Jones
0 siblings, 1 reply; 5+ messages in thread
From: Linus Torvalds @ 2019-06-18 20:55 UTC (permalink / raw)
To: Lee Jones
Cc: Amelie Delaunay, Alexandre Torgue, kernel-janitors,
Linux List Kernel Mailing, Dan Carpenter, Maxime Coquelin,
linux-stm32, Linux ARM
On Tue, Jun 18, 2019 at 1:16 AM Lee Jones <lee.jones@linaro.org> wrote:
>
> > Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
>
> Ideally we can get a review too.
Looks fine to me, but obviously somebody should actually _test_ it too.
Linus
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mfd: stmfx: Fix an endian bug in stmfx_irq_handler()
2019-06-18 20:55 ` Linus Torvalds
@ 2019-06-19 5:58 ` Lee Jones
2019-06-20 15:18 ` Amelie DELAUNAY
0 siblings, 1 reply; 5+ messages in thread
From: Lee Jones @ 2019-06-19 5:58 UTC (permalink / raw)
To: Linus Torvalds
Cc: Amelie Delaunay, Alexandre Torgue, kernel-janitors,
Linux List Kernel Mailing, Dan Carpenter, Maxime Coquelin,
linux-stm32, Linux ARM
On Tue, 18 Jun 2019, Linus Torvalds wrote:
> On Tue, Jun 18, 2019 at 1:16 AM Lee Jones <lee.jones@linaro.org> wrote:
> >
> > > Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
> >
> > Ideally we can get a review too.
>
> Looks fine to me, but obviously somebody should actually _test_ it too.
Amelie, would you be so kind?
--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mfd: stmfx: Fix an endian bug in stmfx_irq_handler()
2019-06-19 5:58 ` Lee Jones
@ 2019-06-20 15:18 ` Amelie DELAUNAY
0 siblings, 0 replies; 5+ messages in thread
From: Amelie DELAUNAY @ 2019-06-20 15:18 UTC (permalink / raw)
To: Lee Jones, Linus Torvalds
Cc: Alexandre TORGUE, kernel-janitors, Linux List Kernel Mailing,
Dan Carpenter, Maxime Coquelin, linux-stm32, Linux ARM
On 6/19/19 7:58 AM, Lee Jones wrote:
> On Tue, 18 Jun 2019, Linus Torvalds wrote:
>
>> On Tue, Jun 18, 2019 at 1:16 AM Lee Jones <lee.jones@linaro.org> wrote:
>>>
>>>> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
>>>
>>> Ideally we can get a review too.
>>
>> Looks fine to me, but obviously somebody should actually _test_ it too.
>
> Amelie, would you be so kind?
>
Tested on stm32mp157c-ev1.
Tested-by: Amelie Delaunay <amelie.delaunay@st.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-06-20 15:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAHk-=wgTL5sYCGxX8+xQqyBRWRUE05GAdL58+UTG8bYwjFxMkw@mail.gmail.com>
2019-06-17 19:06 ` [PATCH] mfd: stmfx: Fix an endian bug in stmfx_irq_handler() Dan Carpenter
2019-06-18 8:16 ` Lee Jones
2019-06-18 20:55 ` Linus Torvalds
2019-06-19 5:58 ` Lee Jones
2019-06-20 15:18 ` Amelie DELAUNAY
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).