summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorThomas Fourier <fourier.thomas@gmail.com>2025-10-17 09:55:39 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-29 13:59:56 +0100
commit18b7e4b960c27b81213d2232666d34829f7c1a8e (patch)
tree878d69bb58ce374f4e3c7261f5d47ed1280fcb76 /drivers
parent0aa9e273ac76e80fc250081a60855310b114ed76 (diff)
downloadlinux-18b7e4b960c27b81213d2232666d34829f7c1a8e.tar.gz
linux-18b7e4b960c27b81213d2232666d34829f7c1a8e.tar.bz2
linux-18b7e4b960c27b81213d2232666d34829f7c1a8e.zip
media: cx18: Add missing check after DMA map
[ Upstream commit 23b53639a793477326fd57ed103823a8ab63084f ] The DMA map functions can fail and should be tested for errors. If the mapping fails, dealloc buffers, and return. Fixes: 1c1e45d17b66 ("V4L/DVB (7786): cx18: new driver for the Conexant CX23418 MPEG encoder chip") Cc: stable@vger.kernel.org Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> [ removed pci_map_single() replaced by dma_map_single() ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/pci/cx18/cx18-queue.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/media/pci/cx18/cx18-queue.c b/drivers/media/pci/cx18/cx18-queue.c
index 2f5df471dada..9b247ecf48d5 100644
--- a/drivers/media/pci/cx18/cx18-queue.c
+++ b/drivers/media/pci/cx18/cx18-queue.c
@@ -379,14 +379,22 @@ int cx18_stream_alloc(struct cx18_stream *s)
break;
}
+ buf->dma_handle = dma_map_single(&s->cx->pci_dev->dev,
+ buf->buf, s->buf_size,
+ s->dma);
+ if (dma_mapping_error(&s->cx->pci_dev->dev, buf->dma_handle)) {
+ kfree(buf->buf);
+ kfree(mdl);
+ kfree(buf);
+ break;
+ }
+
INIT_LIST_HEAD(&mdl->list);
INIT_LIST_HEAD(&mdl->buf_list);
mdl->id = s->mdl_base_idx; /* a somewhat safe value */
cx18_enqueue(s, mdl, &s->q_idle);
INIT_LIST_HEAD(&buf->list);
- buf->dma_handle = pci_map_single(s->cx->pci_dev,
- buf->buf, s->buf_size, s->dma);
cx18_buf_sync_for_cpu(s, buf);
list_add_tail(&buf->list, &s->buf_pool);
}