mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-09-26 17:10:55 +10:00
dmaengine: nbpfaxi: Add missing check after DMA map
[ Upstream commitc6ee78fc8f
] The DMA map functions can fail and should be tested for errors. If the mapping fails, unmap and return an error. Fixes:b45b262cef
("dmaengine: add a driver for AMBA AXI NBPF DMAC IP cores") Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com> Link: https://lore.kernel.org/r/20250707075752.28674-2-fourier.thomas@gmail.com Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
25bfa98cc1
commit
f6ac1449c2
@ -712,6 +712,9 @@ static int nbpf_desc_page_alloc(struct nbpf_channel *chan)
|
||||
list_add_tail(&ldesc->node, &lhead);
|
||||
ldesc->hwdesc_dma_addr = dma_map_single(dchan->device->dev,
|
||||
hwdesc, sizeof(*hwdesc), DMA_TO_DEVICE);
|
||||
if (dma_mapping_error(dchan->device->dev,
|
||||
ldesc->hwdesc_dma_addr))
|
||||
goto unmap_error;
|
||||
|
||||
dev_dbg(dev, "%s(): mapped 0x%p to %pad\n", __func__,
|
||||
hwdesc, &ldesc->hwdesc_dma_addr);
|
||||
@ -738,6 +741,16 @@ static int nbpf_desc_page_alloc(struct nbpf_channel *chan)
|
||||
spin_unlock_irq(&chan->lock);
|
||||
|
||||
return ARRAY_SIZE(dpage->desc);
|
||||
|
||||
unmap_error:
|
||||
while (i--) {
|
||||
ldesc--; hwdesc--;
|
||||
|
||||
dma_unmap_single(dchan->device->dev, ldesc->hwdesc_dma_addr,
|
||||
sizeof(hwdesc), DMA_TO_DEVICE);
|
||||
}
|
||||
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
static void nbpf_desc_put(struct nbpf_desc *desc)
|
||||
|
Loading…
Reference in New Issue
Block a user