linux/drivers/media/test-drivers/vimc
Guangshuo Li 33e2b833c6 media: vimc: fix reference leak on failed device registration
When platform_device_register() fails in vimc_init(), the embedded
struct device in vimc_pdev has already been initialized by
device_initialize(), but the failure path returns the error without
dropping the device reference for the current platform device:

  vimc_init()
    -> platform_device_register(&vimc_pdev)
       -> device_initialize(&vimc_pdev.dev)
       -> setup_pdev_dma_masks(&vimc_pdev)
       -> platform_device_add(&vimc_pdev)

This leads to a reference leak when platform_device_register() fails.
Fix this by calling platform_device_put() before returning the error.

The issue was identified by a static analysis tool I developed and
confirmed by manual review.

Fixes: 4babf057c1 ("media: vimc: allocate vimc_device dynamically")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
2026-05-05 16:57:02 +02:00
..
Kconfig media: Kconfig: cleanup VIDEO_DEV dependencies 2022-03-18 05:58:35 +01:00
Makefile media: vimc: add ancillary lens 2022-07-15 14:40:09 +01:00
vimc-capture.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
vimc-common.c media: vimc: Initialize subdev active state 2024-06-26 16:39:34 +02:00
vimc-common.h media: vimc: sensor: Add pixel_rate,vblank and hblank configuration 2026-03-17 10:50:19 +01:00
vimc-core.c media: vimc: fix reference leak on failed device registration 2026-05-05 16:57:02 +02:00
vimc-debayer.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
vimc-lens.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
vimc-scaler.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
vimc-sensor.c media: vimc: sensor: Add pixel_rate,vblank and hblank configuration 2026-03-17 10:50:19 +01:00
vimc-streamer.c media: vimc: streamer: Apply sensor frame rate in streamer thread 2026-03-17 10:50:19 +01:00
vimc-streamer.h