]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: pci: ivtv: Add missing check after DMA map
authorThomas Fourier <fourier.thomas@gmail.com>
Fri, 17 Oct 2025 14:32:42 +0000 (10:32 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Oct 2025 12:59:56 +0000 (13:59 +0100)
[ Upstream commit 1069a4fe637d0e3e4c163e3f8df9be306cc299b4 ]

The DMA map functions can fail and should be tested for errors.
If the mapping fails, free blanking_ptr and set it to 0.  As 0 is a
valid DMA address, use blanking_ptr to test if the DMA address
is set.

Fixes: 1a0adaf37c30 ("V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder")
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/pci/ivtv/ivtv-irq.c
drivers/media/pci/ivtv/ivtv-yuv.c

index b7aaa8b4a7841dd58c0c8aeeafdacfeab87da86f..e39bf64c5c715bcaa867cbfc5acf71f0d47a0722 100644 (file)
@@ -351,7 +351,7 @@ void ivtv_dma_stream_dec_prepare(struct ivtv_stream *s, u32 offset, int lock)
 
        /* Insert buffer block for YUV if needed */
        if (s->type == IVTV_DEC_STREAM_TYPE_YUV && f->offset_y) {
-               if (yi->blanking_dmaptr) {
+               if (yi->blanking_ptr) {
                        s->sg_pending[idx].src = yi->blanking_dmaptr;
                        s->sg_pending[idx].dst = offset;
                        s->sg_pending[idx].size = 720 * 16;
index 922e64bad10d7b3f9aead3de20ac22c02877d47f..1b101b032a35207f4701f92d1d373e2290dda776 100644 (file)
@@ -125,7 +125,7 @@ static int ivtv_yuv_prep_user_dma(struct ivtv *itv, struct ivtv_user_dma *dma,
        ivtv_udma_fill_sg_array(dma, y_buffer_offset, uv_buffer_offset, y_size);
 
        /* If we've offset the y plane, ensure top area is blanked */
-       if (f->offset_y && yi->blanking_dmaptr) {
+       if (f->offset_y && yi->blanking_ptr) {
                dma->SGarray[dma->SG_length].size = cpu_to_le32(720*16);
                dma->SGarray[dma->SG_length].src = cpu_to_le32(yi->blanking_dmaptr);
                dma->SGarray[dma->SG_length].dst = cpu_to_le32(IVTV_DECODER_OFFSET + yuv_offset[frame]);
@@ -929,6 +929,12 @@ static void ivtv_yuv_init(struct ivtv *itv)
                yi->blanking_dmaptr = dma_map_single(&itv->pdev->dev,
                                                     yi->blanking_ptr,
                                                     720 * 16, DMA_TO_DEVICE);
+               if (dma_mapping_error(&itv->pdev->dev, yi->blanking_dmaptr)) {
+                       kfree(yi->blanking_ptr);
+                       yi->blanking_ptr = NULL;
+                       yi->blanking_dmaptr = 0;
+                       IVTV_DEBUG_WARN("Failed to dma_map yuv blanking buffer\n");
+               }
        } else {
                yi->blanking_dmaptr = 0;
                IVTV_DEBUG_WARN("Failed to allocate yuv blanking buffer\n");