]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
media: nuvoton: npcm-video: fix memory leaks in probe and remove
authorDavid Carlier <devnexen@gmail.com>
Sat, 28 Mar 2026 18:18:09 +0000 (18:18 +0000)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 5 May 2026 14:57:02 +0000 (16:57 +0200)
commit50cc0e547da50b887e63dfa1ad203cd5b735d01e
tree569858a217f96ac65eeb95d3adebd5f73f222a0d
parent60ca00792bce46ec170c7ed101f376186d4cf8a9
media: nuvoton: npcm-video: fix memory leaks in probe and remove

npcm_video_probe() allocates the npcm_video structure with kzalloc_obj()
but never frees it on any probe error path or in npcm_video_remove(),
leaking the allocation on every failed probe and every normal unbind.

Additionally, when npcm_video_setup_video() fails, the reserved memory
association established by of_reserved_mem_device_init() in
npcm_video_init() is not released, leaking the rmem_assigned_device
entry on the global list.

Fix both by adding kfree(video) to all probe error paths and to
npcm_video_remove(), and adding the missing
of_reserved_mem_device_release() call when npcm_video_setup_video()
fails.

Fixes: 46c15a4ff1f4 ("media: nuvoton: Add driver for NPCM video capture and encoding engine")
Cc: stable@vger.kernel.org
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/nuvoton/npcm-video.c