From: Guangshuo Li <lgs201920130244@gmail.com>
To: Helge Deller <deller@gmx.de>,
Guangshuo Li <lgs201920130244@gmail.com>,
Andriy Skulysh <askulysh@gmail.com>,
Paul Mundt <lethal@linux-sh.org>,
linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH] fbdev: hitfb: fix reference leak on failed device registration
Date: Thu, 16 Apr 2026 03:10:03 +0800 [thread overview]
Message-ID: <20260415191003.3829558-1-lgs201920130244@gmail.com> (raw)
When platform_device_register() fails in hitfb_init(), the embedded
struct device in hitfb_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:
hitfb_init()
-> platform_device_register(&hitfb_device)
-> device_initialize(&hitfb_device.dev)
-> setup_pdev_dma_masks(&hitfb_device)
-> platform_device_add(&hitfb_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.
Fixes: 048839dc548a5 ("video: hitfb suspend/resume and updates.")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
drivers/video/fbdev/hitfb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/hitfb.c b/drivers/video/fbdev/hitfb.c
index 97db325df2b4..29708c2d506d 100644
--- a/drivers/video/fbdev/hitfb.c
+++ b/drivers/video/fbdev/hitfb.c
@@ -495,8 +495,10 @@ static int __init hitfb_init(void)
ret = platform_driver_register(&hitfb_driver);
if (!ret) {
ret = platform_device_register(&hitfb_device);
- if (ret)
+ if (ret) {
+ platform_device_put(&hitfb_device);
platform_driver_unregister(&hitfb_driver);
+ }
}
return ret;
}
--
2.43.0
reply other threads:[~2026-04-15 19:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260415191003.3829558-1-lgs201920130244@gmail.com \
--to=lgs201920130244@gmail.com \
--cc=askulysh@gmail.com \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=lethal@linux-sh.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox