Skip to content

Commit

Permalink
dmaengine: jz4780: Fix an endian bug in IRQ handler
Browse files Browse the repository at this point in the history
commit 4c89cc7 upstream.

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: 4e4106f ("dmaengine: jz4780: Fix transfers being ACKed too soon")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Jul 10, 2019
1 parent 598ffd8 commit abedf70
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/dma/dma-jz4780.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,12 +722,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);
}
Expand Down

0 comments on commit abedf70

Please sign in to comment.