]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: dm1105: fix missing error check for dma_alloc_coherent
authorZhaoyang Yu <2426767509@qq.com>
Wed, 15 Apr 2026 14:49:09 +0000 (14:49 +0000)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 5 May 2026 14:57:02 +0000 (16:57 +0200)
The return value of dm1105_dma_map(), which handles DMA memory allocation,
is ignored in dm1105_hw_init(). If dma_alloc_coherent() fails, the driver
will proceed using a NULL pointer for DMA transfers, leading to a kernel
oops or invalid hardware access.

Fix this by checking the return value and propagating -ENOMEM on failure.

Signed-off-by: Zhaoyang Yu <2426767509@qq.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/pci/dm1105/dm1105.c

index bbd24769ae56be35e7eede52517ed6832b9327a0..c33d811cbafa4bde25b705f82a08865d37b282d0 100644 (file)
@@ -768,6 +768,8 @@ static void dm1105_ir_exit(struct dm1105_dev *dm1105)
 
 static int dm1105_hw_init(struct dm1105_dev *dev)
 {
+       int ret;
+
        dm1105_disable_irqs(dev);
 
        dm_writeb(DM1105_HOST_CTR, 0);
@@ -778,7 +780,10 @@ static int dm1105_hw_init(struct dm1105_dev *dev)
        dm_writew(DM1105_TSCTR, 0xc10a);
 
        /* map DMA and set address */
-       dm1105_dma_map(dev);
+       ret = dm1105_dma_map(dev);
+       if (ret)
+               return -ENOMEM;
+
        dm1105_set_dma_addr(dev);
        /* big buffer */
        dm_writel(DM1105_RLEN, 5 * DM1105_DMA_BYTES);