]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
media: saa7134: Fix a possible memory leak in saa7134_video_init1
authorMa Ke <make24@iscas.ac.cn>
Thu, 2 Apr 2026 07:35:29 +0000 (15:35 +0800)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 6 May 2026 07:05:56 +0000 (09:05 +0200)
commitf86ed548386e3050e5f8f25b450d09dc009d9a88
treea539f543785b9640612c2cee159c5dc6c0a0b40b
parent7d6358ab02866e5b7ed8d3a00805297617bbb0ec
media: saa7134: Fix a possible memory leak in saa7134_video_init1

In saa7134_video_init1(), the return value of the first
saa7134_pgtable_alloc() is not checked. If it fails, the function
continues as if successful, leaving the driver with an invalid page
table. Additionally, if vb2_queue_init() for the VBI queue fails after
the video queue page table has been allocated, the allocated memory is
not freed before returning. The second saa7134_pgtable_alloc() also
lacks a return value check. Errors occur during device probing before
the device is fully registered, the normal cleanup path in
saa7134_finidev() is not executed, leading to memory leaks and
potential use of uninitialized DMA resources.

Check the return value of both saa7134_pgtable_alloc() calls and
propagate errors. On failure of any later step, free allocated page
tables to avoid memory leaks. Ensure control handlers are also
released on error to prevent further resource leakage.

Found by code review.

Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Cc: stable@vger.kernel.org
Fixes: a00e68888d5d ("[media] saa7134: move saa7134_pgtable to saa7134_dmaqueue")
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/pci/saa7134/saa7134-video.c