firmware: sysfb: Clear the device pointer on registration failure
Subsystems (2)
PATCH 1/1 firmware: sysfb: Clear the device pointer on registration failure
sysfb_init() stores the legacy framebuffer device in the file-scope pd pointer before adding its data and registering it. If either operation fails, the error path drops the allocation reference but leaves pd set. A later sysfb_disable() then passes this stale pointer to platform_device_unregister().
Clear pd after releasing the failed device, while disable_lock is still held. This makes sysfb_unregister() skip it just as it skips an absent or already unregistered framebuffer.
---
AI assistance was used for analysis and patch preparation.
Based on next-20261104 (8b7179210b22).
Compile-tested: x86_64, GCC 14.2.0, W=1, drivers/firmware/sysfb.o; baseline and patched objects built with no warnings. Static source review; no hardware, boot, or KASAN test was performed.
drivers/firmware/sysfb.c | 1 + 1 file changed, 1 insertion(+)
drivers/firmware/sysfb.c +1 -0
@@ -214,6 +214,7 @@ static __init int sysfb_init(void) goto put_device; err:platform_device_put (pd); + pd =NULL ; put_device:put_device (parent); unlock_mutex:
base-commit: 8b7179210b22f8e48a82c5ceacb9d56a9c4cfec4
Am 24.11.26 um 16:45 schrieb Yige Jiang:
Quoted 6 lines
sysfb_init()stores the legacy framebuffer device in the file-scope pd pointer before adding its data and registering it. If either operation fails, the error path drops the allocation reference but leaves pd set. A latersysfb_disable()then passes this stale pointer toplatform_device_unregister().
Quoted 7 lines
Clear pd after releasing the failed device, while
disable_lockis still held. This makessysfb_unregister()skip it just as it skips an absent or already unregistered framebuffer.Fixes bde376e9de3c ("firmware: sysfb: Add sysfb_disable() helper function")Signed-off-by Yige Jiang <[email protected]>
Thanks!
Quoted 25 lines
---
AI assistance was used for analysis and patch preparation.Based on next-20261104 (
8b7179210b22).
Compile-tested:x86_64, GCC 14.2.0, W=1,drivers/firmware/sysfb.o; baseline and patched objects built with no warnings. Static source review; no hardware, boot, or KASAN test was performed.drivers/firmware/sysfb.c | 1 + 1 file changed, 1 insertion(+)drivers/firmware/sysfb.c +1
-0@@ -214,6 +214,7 @@ static __init int sysfb_init(void) goto put_device; err:platform_device_put (pd); + pd =NULL ; put_device:put_device (parent); unlock_mutex:base-commit:
8b7179210b22f8e48a82c5ceacb9d56a9c4cfec4
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)
Yige Jiang <[email protected]> writes:
Hello,
Quoted 6 lines
sysfb_init()stores the legacy framebuffer device in the file-scope pd pointer before adding its data and registering it. If either operation fails, the error path drops the allocation reference but leaves pd set. A latersysfb_disable()then passes this stale pointer toplatform_device_unregister().
Quoted 8 lines
Clear pd after releasing the failed device, while
disable_lockis still held. This makessysfb_unregister()skip it just as it skips an absent or already unregistered framebuffer.Fixes bde376e9de3c ("firmware: sysfb: Add sysfb_disable() helper function")Signed-off-by Yige Jiang <[email protected]>---
Thanks for the fix.
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat