* [PATCH] dmaengine: jz4780: Fix an endian bug in IRQ handler
@ 2019-06-24 13:49 Dan Carpenter
2019-07-05 7:16 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-06-24 13:49 UTC (permalink / raw)
To: Zubair Lutfullah Kakakhel, Paul Cercueil
Cc: Vinod Koul, Dan Williams, dmaengine, kernel-janitors
The "pending" variable was a u32 but we cast it to an unsigned long
pointer when we do the for_each_set_bit() loop. The problem is that on
big endian 64bit systems that results in an out of bounds read.
Fixes: 4e4106f5e942 ("dmaengine: jz4780: Fix transfers being ACKed too soon")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I don't know if this driver is ever used on a big endian 64 bit system,
but the fix is pretty easy and it silences a static checker warning.
Not tested.
drivers/dma/dma-jz4780.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c
index 77260a6f5178..dfd10fe3c9b3 100644
--- a/drivers/dma/dma-jz4780.c
+++ b/drivers/dma/dma-jz4780.c
@@ -717,12 +717,13 @@ static irqreturn_t jz4780_dma_irq_handler(int irq, void *data)
{
struct jz4780_dma_dev *jzdma = data;
unsigned int nb_channels = jzdma->soc_data->nb_channels;
- uint32_t pending, dmac;
+ unsigned long pending;
+ uint32_t dmac;
int i;
pending = jz4780_dma_ctrl_readl(jzdma, JZ_DMA_REG_DIRQP);
- for_each_set_bit(i, (unsigned long *)&pending, nb_channels) {
+ for_each_set_bit(i, &pending, nb_channels) {
if (jz4780_dma_chan_irq(jzdma, &jzdma->chan[i]))
pending &= ~BIT(i);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dmaengine: jz4780: Fix an endian bug in IRQ handler
2019-06-24 13:49 [PATCH] dmaengine: jz4780: Fix an endian bug in IRQ handler Dan Carpenter
@ 2019-07-05 7:16 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2019-07-05 7:16 UTC (permalink / raw)
To: Dan Carpenter
Cc: Zubair Lutfullah Kakakhel, Paul Cercueil, Dan Williams,
dmaengine, kernel-janitors
On 24-06-19, 16:49, Dan Carpenter wrote:
> The "pending" variable was a u32 but we cast it to an unsigned long
> pointer when we do the for_each_set_bit() loop. The problem is that on
> big endian 64bit systems that results in an out of bounds read.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-05 7:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24 13:49 [PATCH] dmaengine: jz4780: Fix an endian bug in IRQ handler Dan Carpenter
2019-07-05 7:16 ` Vinod Koul
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).