diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-03-25 13:45:10 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-03-25 13:45:10 -0400 |
| commit | cb6416592bc2a8b731dabcec0d63cda270764fc6 (patch) | |
| tree | 75cf1ef5080a24f66f482670953892c6baf4d168 | |
| parent | d2862360bfe54fd63618dbabf09191c4c0dc7576 (diff) | |
| parent | 3e4543bf20531d1cdb8672d25b3f2ff6d3d07627 (diff) | |
Merge tag 'dmaengine-fix-4.16-rc7' of git://git.kernel.org/pub/scm/linux/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
| -rw-r--r-- | drivers/dma/stm32-dmamux.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/dma/stm32-dmamux.c b/drivers/dma/stm32-dmamux.c index 4dbb30cf94ac..b922db90939a 100644 --- a/drivers/dma/stm32-dmamux.c +++ b/drivers/dma/stm32-dmamux.c | |||
| @@ -118,14 +118,15 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec, | |||
| 118 | spin_lock_irqsave(&dmamux->lock, flags); | 118 | spin_lock_irqsave(&dmamux->lock, flags); |
| 119 | mux->chan_id = find_first_zero_bit(dmamux->dma_inuse, | 119 | mux->chan_id = find_first_zero_bit(dmamux->dma_inuse, |
| 120 | dmamux->dma_requests); | 120 | dmamux->dma_requests); |
| 121 | set_bit(mux->chan_id, dmamux->dma_inuse); | ||
| 122 | spin_unlock_irqrestore(&dmamux->lock, flags); | ||
| 123 | 121 | ||
| 124 | if (mux->chan_id == dmamux->dma_requests) { | 122 | if (mux->chan_id == dmamux->dma_requests) { |
| 123 | spin_unlock_irqrestore(&dmamux->lock, flags); | ||
| 125 | dev_err(&pdev->dev, "Run out of free DMA requests\n"); | 124 | dev_err(&pdev->dev, "Run out of free DMA requests\n"); |
| 126 | ret = -ENOMEM; | 125 | ret = -ENOMEM; |
| 127 | goto error; | 126 | goto error_chan_id; |
| 128 | } | 127 | } |
| 128 | set_bit(mux->chan_id, dmamux->dma_inuse); | ||
| 129 | spin_unlock_irqrestore(&dmamux->lock, flags); | ||
| 129 | 130 | ||
| 130 | /* Look for DMA Master */ | 131 | /* Look for DMA Master */ |
| 131 | for (i = 1, min = 0, max = dmamux->dma_reqs[i]; | 132 | for (i = 1, min = 0, max = dmamux->dma_reqs[i]; |
| @@ -173,6 +174,8 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec, | |||
| 173 | 174 | ||
| 174 | error: | 175 | error: |
| 175 | clear_bit(mux->chan_id, dmamux->dma_inuse); | 176 | clear_bit(mux->chan_id, dmamux->dma_inuse); |
| 177 | |||
| 178 | error_chan_id: | ||
| 176 | kfree(mux); | 179 | kfree(mux); |
| 177 | return ERR_PTR(ret); | 180 | return ERR_PTR(ret); |
| 178 | } | 181 | } |
