drivers/video/fbdev/q40fb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
When platform_device_register() fails in q40fb_init(), the embedded
struct device in q40fb_device has already been initialized by
device_initialize(), but the failure path only unregisters the platform
driver and does not drop the device reference for the current platform
device:
q40fb_init()
-> platform_device_register(&q40fb_device)
-> device_initialize(&q40fb_device.dev)
-> setup_pdev_dma_masks(&q40fb_device)
-> platform_device_add(&q40fb_device)
This leads to a reference leak when platform_device_register() fails.
Fix this by calling platform_device_put() before unregistering the
platform driver.
The issue was identified by a static analysis tool I developed and
confirmed by manual review.
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
drivers/video/fbdev/q40fb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/q40fb.c b/drivers/video/fbdev/q40fb.c
index 1ff8fa176124..0151a41267b3 100644
--- a/drivers/video/fbdev/q40fb.c
+++ b/drivers/video/fbdev/q40fb.c
@@ -141,8 +141,10 @@ static int __init q40fb_init(void)
if (!ret) {
ret = platform_device_register(&q40fb_device);
- if (ret)
+ if (ret) {
+ platform_device_put(&q40fb_device);
platform_driver_unregister(&q40fb_driver);
+ }
}
return ret;
}
--
2.43.0
Hi,
Please disregard this patch.
On Thu, 16 Apr 2026 at 03:13, Guangshuo Li <lgs201920130244@gmail.com> wrote:
>
> When platform_device_register() fails in q40fb_init(), the embedded
> struct device in q40fb_device has already been initialized by
> device_initialize(), but the failure path only unregisters the platform
> driver and does not drop the device reference for the current platform
> device:
>
> q40fb_init()
> -> platform_device_register(&q40fb_device)
> -> device_initialize(&q40fb_device.dev)
> -> setup_pdev_dma_masks(&q40fb_device)
> -> platform_device_add(&q40fb_device)
>
> This leads to a reference leak when platform_device_register() fails.
> Fix this by calling platform_device_put() before unregistering the
> platform driver.
>
> The issue was identified by a static analysis tool I developed and
> confirmed by manual review.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
> drivers/video/fbdev/q40fb.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/video/fbdev/q40fb.c b/drivers/video/fbdev/q40fb.c
> index 1ff8fa176124..0151a41267b3 100644
> --- a/drivers/video/fbdev/q40fb.c
> +++ b/drivers/video/fbdev/q40fb.c
> @@ -141,8 +141,10 @@ static int __init q40fb_init(void)
>
> if (!ret) {
> ret = platform_device_register(&q40fb_device);
> - if (ret)
> + if (ret) {
> + platform_device_put(&q40fb_device);
> platform_driver_unregister(&q40fb_driver);
> + }
> }
> return ret;
> }
> --
> 2.43.0
>
After re-checking it, q40fb_device is a static platform_device and it does
not provide a dev.release callback. Therefore calling
platform_device_put() on the platform_device_register() failure path is
not appropriate here and can trigger the missing release callback
warning.
This falls into the same static platform_device pattern pointed out in
the other reviews, so I will drop this patch.
Sorry for the noise.
Best regards,
Guangshuo Li
© 2016 - 2026 Red Hat, Inc.