[PATCH] fbdev: omapfb: fix reference leak on failed device registration
From: Guangshuo Li
Date: Wed Apr 15 2026 - 15:18:13 EST
When platform_device_register() fails in omapfb_probe(), the embedded
struct device in omapdss_device has already been initialized by
device_initialize(), but the failure path only reports the error and
returns without dropping the device reference for the current platform
device:
omapfb_probe()
-> platform_device_register(&omapdss_device)
-> device_initialize(&omapdss_device.dev)
-> setup_pdev_dma_masks(&omapdss_device)
-> platform_device_add(&omapdss_device)
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: f778a12dd3320 ("OMAP: OMAPFB: fix clk_get for RFBI")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Guangshuo Li <lgs201920130244@xxxxxxxxx>
---
drivers/video/fbdev/omap/omapfb_main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/video/fbdev/omap/omapfb_main.c b/drivers/video/fbdev/omap/omapfb_main.c
index cafe859d6e5a..0d47a8aec5c5 100644
--- a/drivers/video/fbdev/omap/omapfb_main.c
+++ b/drivers/video/fbdev/omap/omapfb_main.c
@@ -1768,6 +1768,7 @@ static int omapfb_probe(struct platform_device *pdev)
r = platform_device_register(&omapdss_device);
if (r) {
dev_err(&pdev->dev, "can't register omapdss device\n");
+ platform_device_put(&omapdss_device);
return r;
}
--
2.43.0