]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
media: tegra-video: Fix memory leak in __tegra_channel_try_format()
authorZilin Guan <zilin@seu.edu.cn>
Fri, 14 Nov 2025 09:12:57 +0000 (09:12 +0000)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 13 Jan 2026 12:10:07 +0000 (13:10 +0100)
commit43e5302d22334f1183dec3e0d5d8007eefe2817c
tree9f922bfe8825929133f95d18d243ca1b6666dc34
parent42bf68dfef7e737933674bd56e1159950247b094
media: tegra-video: Fix memory leak in __tegra_channel_try_format()

The state object allocated by __v4l2_subdev_state_alloc() must be freed
with __v4l2_subdev_state_free() when it is no longer needed.

In __tegra_channel_try_format(), two error paths return directly after
v4l2_subdev_call() fails, without freeing the allocated 'sd_state'
object. This violates the requirement and causes a memory leak.

Fix this by introducing a cleanup label and using goto statements in the
error paths to ensure that __v4l2_subdev_state_free() is always called
before the function returns.

Fixes: 56f64b82356b7 ("media: tegra-video: Use zero crop settings if subdev has no get_selection")
Fixes: 1ebaeb09830f3 ("media: tegra-video: Add support for external sensor capture")
Cc: stable@vger.kernel.org
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/staging/media/tegra-video/vi.c