* [PATCH] fbdev: cobalt_lcdfb: Don't read info after framebuffer_release()
@ 2026-11-18 14:07 Suyuan Wang via B4 Relay
2026-11-18 19:06 ` Helge Deller
0 siblings, 1 reply; 2+ messages in thread
From: Suyuan Wang via B4 Relay @ 2026-11-18 14:07 UTC (permalink / raw)
To: deller; +Cc: dri-devel, yoichi_yuasa, linux-fbdev, linux-kernel
From: Suyuan Wang <stevewong@hust.edu.cn>
When devm_platform_get_and_ioremap_resource() fails, cobalt_lcdfb_probe()
releases the framebuffer and then dereferences it for the return value:
framebuffer_release(info);
return PTR_ERR(info->screen_base);
framebuffer_release() frees info, so info->screen_base is read from freed
memory. Save the error code before releasing info.
Found with a static analysis tool and checked by hand.
Fixes: d2386d9e3eb4 ("fbdev: cobalt_lcdfb: Request memory region")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
---
The change only moves the error-code read before framebuffer_release().
Checked by inspection; I couldn't build it here (MIPS, and my MIPS cross
toolchain fails at an unrelated host step), and I don't have the
hardware.
---
drivers/video/fbdev/cobalt_lcdfb.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c
index f7faa95fefd3..e90f45c91725 100644
--- a/drivers/video/fbdev/cobalt_lcdfb.c
+++ b/drivers/video/fbdev/cobalt_lcdfb.c
@@ -297,8 +297,9 @@ static int cobalt_lcdfb_probe(struct platform_device *dev)
info->screen_base = devm_platform_get_and_ioremap_resource(dev, 0, &res);
if (IS_ERR(info->screen_base)) {
+ retval = PTR_ERR(info->screen_base);
framebuffer_release(info);
- return PTR_ERR(info->screen_base);
+ return retval;
}
info->screen_size = resource_size(res);
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] fbdev: cobalt_lcdfb: Don't read info after framebuffer_release()
2026-11-18 14:07 [PATCH] fbdev: cobalt_lcdfb: Don't read info after framebuffer_release() Suyuan Wang via B4 Relay
@ 2026-11-18 19:06 ` Helge Deller
0 siblings, 0 replies; 2+ messages in thread
From: Helge Deller @ 2026-11-18 19:06 UTC (permalink / raw)
To: shyckless; +Cc: dri-devel, linux-fbdev, linux-kernel
On 11/18/26 15:07, Suyuan Wang via B4 Relay wrote:
> From: Suyuan Wang <stevewong@hust.edu.cn>
>
> When devm_platform_get_and_ioremap_resource() fails, cobalt_lcdfb_probe()
> releases the framebuffer and then dereferences it for the return value:
>
> framebuffer_release(info);
> return PTR_ERR(info->screen_base);
>
> framebuffer_release() frees info, so info->screen_base is read from freed
> memory. Save the error code before releasing info.
>
> Found with a static analysis tool and checked by hand.
>
> Fixes: d2386d9e3eb4 ("fbdev: cobalt_lcdfb: Request memory region")
> Cc: stable@vger.kernel.org
> Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
> Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
> Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
> ---
> The change only moves the error-code read before framebuffer_release().
> Checked by inspection; I couldn't build it here (MIPS, and my MIPS cross
> toolchain fails at an unrelated host step), and I don't have the
> hardware.
> ---
> drivers/video/fbdev/cobalt_lcdfb.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
applied.
Thanks!
Helge
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-18 19:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 14:07 [PATCH] fbdev: cobalt_lcdfb: Don't read info after framebuffer_release() Suyuan Wang via B4 Relay
2026-11-18 19:06 ` Helge Deller
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®