From: Suyuan Wang via B4 Relay <devnull+shyckless.gmail.com@kernel.org>
To: deller@gmx.de
Cc: dri-devel@lists.freedesktop.org, yoichi_yuasa@tripeaks.co.jp,
linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fbdev: cobalt_lcdfb: Don't read info after framebuffer_release()
Date: Wed, 18 Nov 2026 14:07:31 +0000 [thread overview]
Message-ID: <20261118-cobalt-lcdfb-v1-1-214062966e2c@gmail.com> (raw)
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);
reply other threads:[~2026-11-18 14:07 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=20261118-cobalt-lcdfb-v1-1-214062966e2c@gmail.com \
--to=devnull+shyckless.gmail.com@kernel.org \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shyckless@gmail.com \
--cc=yoichi_yuasa@tripeaks.co.jp \
/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
all inboxes | Powered by JetHome®