linux/drivers/staging/most
Guangshuo Li 7cb1c5b32a staging: most: video: avoid double free on video register failure
comp_register_videodev() allocates a video_device with
video_device_alloc() and releases it if video_register_device() fails.

This can double free the video_device when __video_register_device()
reaches device_register() and that call fails:

  video_register_device()
    -> __video_register_device()
       -> device_register() fails
          -> put_device(&vdev->dev)
             -> v4l2_device_release()
                -> vdev->release(vdev)
                   -> video_device_release(vdev)

  comp_register_videodev()
    -> video_device_release(mdev->vdev)

Use video_device_release_empty() while registering the device so that
registration failure paths do not free mdev->vdev through vdev->release().
comp_register_videodev() then releases mdev->vdev exactly once on failure.
Restore video_device_release() after successful registration so the
registered device keeps its normal lifetime handling.

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

Fixes: eab231c039 ("staging: most: v4l2-aim: remove unnecessary label err_vbi_dev")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Link: https://patch.msgid.link/20260517111218.945796-1-lgs201920130244@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-05-21 12:42:38 +02:00
..
dim2 staging: most: dim2: remove filename from comment blocks 2026-05-04 16:17:58 +02:00
Documentation staging: most: fix typos in driver_usage.txt 2026-03-09 17:50:13 +01:00
net staging: most: net: replace pr_err with netdev_err 2026-05-11 09:58:02 +02:00
video staging: most: video: avoid double free on video register failure 2026-05-21 12:42:38 +02:00
Kconfig staging: most: remove broken i2c driver 2025-11-09 11:16:09 +09:00
Makefile staging: most: remove broken i2c driver 2025-11-09 11:16:09 +09:00
TODO staging: most: Remove TODO contact information 2024-11-10 08:03:31 +01:00