mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] firmware: sysfb: Clear the device pointer on registration failure
@ 2026-11-24 15:45 Yige Jiang
  2026-11-25  7:27 ` Thomas Zimmermann
  2026-11-25  8:42 ` Javier Martinez Canillas
  0 siblings, 2 replies; 3+ messages in thread
From: Yige Jiang @ 2026-11-24 15:45 UTC (permalink / raw)
  To: Thomas Zimmermann, Javier Martinez Canillas
  Cc: Yige Jiang, dri-devel, linux-kernel, stable

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.

Fixes: bde376e9de3c ("firmware: sysfb: Add sysfb_disable() helper function")
Cc: stable@vger.kernel.org
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
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(+)

diff --git a/drivers/firmware/sysfb.c b/drivers/firmware/sysfb.c
index 8833582c188301afb4a9c9dbdf969828ab9449f6..9cd660a509da939c28e93956d7b6420c794048c1 100644
--- a/drivers/firmware/sysfb.c
+++ b/drivers/firmware/sysfb.c
@@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] firmware: sysfb: Clear the device pointer on registration failure
  2026-11-24 15:45 [PATCH] firmware: sysfb: Clear the device pointer on registration failure Yige Jiang
@ 2026-11-25  7:27 ` Thomas Zimmermann
  2026-11-25  8:42 ` Javier Martinez Canillas
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Zimmermann @ 2026-11-25  7:27 UTC (permalink / raw)
  To: Yige Jiang, Javier Martinez Canillas; +Cc: dri-devel, linux-kernel, stable



Am 24.11.26 um 16:45 schrieb Yige Jiang:
> 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.
>
> Fixes: bde376e9de3c ("firmware: sysfb: Add sysfb_disable() helper function")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yige Jiang <yigejiang86@gmail.com>

Thanks!

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>


> ---
> 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(+)
>
> diff --git a/drivers/firmware/sysfb.c b/drivers/firmware/sysfb.c
> index 8833582c188301afb4a9c9dbdf969828ab9449f6..9cd660a509da939c28e93956d7b6420c794048c1 100644
> --- a/drivers/firmware/sysfb.c
> +++ b/drivers/firmware/sysfb.c
> @@ -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

-- 
--
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)



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] firmware: sysfb: Clear the device pointer on registration failure
  2026-11-24 15:45 [PATCH] firmware: sysfb: Clear the device pointer on registration failure Yige Jiang
  2026-11-25  7:27 ` Thomas Zimmermann
@ 2026-11-25  8:42 ` Javier Martinez Canillas
  1 sibling, 0 replies; 3+ messages in thread
From: Javier Martinez Canillas @ 2026-11-25  8:42 UTC (permalink / raw)
  To: Yige Jiang, Thomas Zimmermann; +Cc: Yige Jiang, dri-devel, linux-kernel, stable

Yige Jiang <yigejiang86@gmail.com> writes:

Hello,

> 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.
>
> Fixes: bde376e9de3c ("firmware: sysfb: Add sysfb_disable() helper function")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
> ---

Thanks for the fix.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-25  8:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 15:45 [PATCH] firmware: sysfb: Clear the device pointer on registration failure Yige Jiang
2026-11-25  7:27 ` Thomas Zimmermann
2026-11-25  8:42 ` Javier Martinez Canillas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®