media: cx18: Add missing check after DMA map

The DMA map functions can fail and should be tested for errors.
If the mapping fails, dealloc buffers, and return.

Fixes: 1c1e45d17b ("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>
This commit is contained in:
Thomas Fourier 2025-07-09 13:35:40 +02:00 committed by Hans Verkuil
parent 2dc344f89f
commit 23b53639a7

View File

@ -379,15 +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 = dma_map_single(&s->cx->pci_dev->dev,
buf->buf, s->buf_size,
s->dma);
cx18_buf_sync_for_cpu(s, buf);
list_add_tail(&buf->list, &s->buf_pool);
}