Skip to content

Commit

Permalink
Merge tag 'dmaengine-fix-4.16-rc7' of git://git.kernel.org/pub/scm/li…
Browse files Browse the repository at this point in the history
…nux/kernel/git/vkoul/slave-dma

Pull dmaengine fix from Vinod Koul:
 "One small fix for stm32-dmamux fixing buffer overflow"

* tag 'dmaengine-fix-4.16-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/slave-dma:
  dmaengine: stm32-dmamux: fix a potential buffer overflow
  • Loading branch information
Linus Torvalds committed Mar 25, 2018
2 parents d286236 + 3e4543b commit cb64165
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/dma/stm32-dmamux.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,15 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
spin_lock_irqsave(&dmamux->lock, flags);
mux->chan_id = find_first_zero_bit(dmamux->dma_inuse,
dmamux->dma_requests);
set_bit(mux->chan_id, dmamux->dma_inuse);
spin_unlock_irqrestore(&dmamux->lock, flags);

if (mux->chan_id == dmamux->dma_requests) {
spin_unlock_irqrestore(&dmamux->lock, flags);
dev_err(&pdev->dev, "Run out of free DMA requests\n");
ret = -ENOMEM;
goto error;
goto error_chan_id;
}
set_bit(mux->chan_id, dmamux->dma_inuse);
spin_unlock_irqrestore(&dmamux->lock, flags);

/* Look for DMA Master */
for (i = 1, min = 0, max = dmamux->dma_reqs[i];
Expand Down Expand Up @@ -173,6 +174,8 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,

error:
clear_bit(mux->chan_id, dmamux->dma_inuse);

error_chan_id:
kfree(mux);
return ERR_PTR(ret);
}
Expand Down

0 comments on commit cb64165

Please sign in to comment.