linux/drivers/media/usb/usbtv
Guangshuo Li bbd4218310 media: usbtv: Fix V4L2 refcount leak on probe failure
usbtv_probe() allocates usbtv before usbtv_video_init() registers its
embedded v4l2_device. v4l2_device_register() initializes the reference
count to one, with usbtv_release() providing the final cleanup.

If video_register_device() fails, usbtv_video_init() unregisters the
V4L2 device and returns an error without dropping the initial
v4l2_device reference. The probe error path then calls kfree() on usbtv
directly, leaving the reference stranded and bypassing
usbtv_release().

Leave the initialized V4L2 device intact on this failure path. After
releasing the USB reference, call v4l2_device_put() so the final
reference invokes usbtv_release(). Retain the direct kfree() path for
failures that occur before v4l2_device_register().

This issue was found by a static analysis tool I am developing.

Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
2026-07-28 15:17:54 +02:00
..
Kconfig media: Kconfig: cleanup VIDEO_DEV dependencies 2022-03-18 05:58:35 +01:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
usbtv-audio.c media: usbtv: keep device alive while ALSA card exists 2026-07-15 17:12:55 +02:00
usbtv-core.c media: usbtv: Fix V4L2 refcount leak on probe failure 2026-07-28 15:17:54 +02:00
usbtv-video.c media: usbtv: Fix V4L2 refcount leak on probe failure 2026-07-28 15:17:54 +02:00
usbtv.h media: usbtv: Add PAL-Nc standard 2022-06-20 10:30:30 +01:00