linux/drivers/staging/media
Zilin Guan 2dff8966a3 media: tegra-video: Fix memory leak in __tegra_channel_try_format()
[ Upstream commit 43e5302d22 ]

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: 56f64b8235 ("media: tegra-video: Use zero crop settings if subdev has no get_selection")
Fixes: 1ebaeb0983 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-03-12 07:09:26 -04:00
..
atomisp media: atomisp: Fix incorrect snprintf format specifiers for signed integers 2025-08-29 11:04:02 +02:00
av7110 media fixes for v6.12-rc7 2024-11-08 07:41:27 -10:00
deprecated/atmel Staging driver changes for 6.13-rc1 2024-11-29 11:36:13 -08:00
imx media: staging: imx: Drop custom .unsubscribe_event() handler 2025-08-25 15:40:33 +02:00
ipu3 staging: media: ipu3: use string_choices API instead of ternary operator 2025-08-25 15:40:31 +02:00
ipu7 media: staging/ipu7: Fix the loop bound in l2 table alloc 2026-03-04 07:21:04 -05:00
max96712 staging: media: max96712: fix kernel oops when removing module 2024-12-19 12:50:19 +01:00
meson/vdec media: Reset file->private_data to NULL in v4l2_fh_del() 2025-08-13 08:33:44 +02:00
starfive media: staging: atomisp/starfive: use (t,l)/wxh format for rectangle 2025-04-30 08:16:06 +02:00
sunxi media: staging: Rename second ioctl handlers argument to 'void *priv' 2025-08-13 08:34:02 +02:00
tegra-video media: tegra-video: Fix memory leak in __tegra_channel_try_format() 2026-03-12 07:09:26 -04:00
Kconfig media: rkvdec: Unstage the driver 2025-07-12 08:34:48 +02:00
Makefile media: rkvdec: Unstage the driver 2025-07-12 08:34:48 +02:00