Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH] fbdev: s3c-fb: Fix potential registration corruption on probe failure
@ 2026-11-18 14:22 Guangshuo Li
  2026-11-18 18:17 ` Helge Deller
  0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-11-18 14:22 UTC (permalink / raw)
  To: Jingoo Han, Helge Deller; +Cc: linux-fbdev, dri-devel, linux-kernel, stable

Probe failure cleanup calls unregister_framebuffer() even when the
window has not been registered. Its zero-initialized node can then
remove another framebuffer from registered_fb[0].

Track successful registration and only unregister those framebuffers.
Also skip empty window slots while unwinding a failed probe.

This issue was found by our static analysis tool under development.

Fixes: ec549a0fdc32 ("fb: add s3c-fb driver for newer Samsung SoC framebuffer devices")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/video/fbdev/s3c-fb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/s3c-fb.c b/drivers/video/fbdev/s3c-fb.c
index 82a3bc9de433..c67ad47a49f0 100644
--- a/drivers/video/fbdev/s3c-fb.c
+++ b/drivers/video/fbdev/s3c-fb.c
@@ -161,6 +161,7 @@ struct s3c_fb_palette {
  * @pseudo_palette: For use in TRUECOLOUR modes for entries 0..15/
  * @index: The window number of this window.
  * @palette: The bitfields for changing r/g/b into a hardware palette entry.
+ * @registered: Whether the framebuffer was successfully registered.
  */
 struct s3c_fb_win {
 	struct s3c_fb_pd_win	*windata;
@@ -172,6 +173,7 @@ struct s3c_fb_win {
 	u32			*palette_buffer;
 	u32			 pseudo_palette[16];
 	unsigned int		 index;
+	bool			 registered;
 };
 
 /**
@@ -1142,14 +1144,15 @@ static void s3c_fb_release_win(struct s3c_fb *sfb, struct s3c_fb_win *win)
 {
 	u32 data;
 
-	if (win->fbinfo) {
+	if (win && win->fbinfo) {
 		if (sfb->variant.has_shadowcon) {
 			data = readl(sfb->regs + SHADOWCON);
 			data &= ~SHADOWCON_CHx_ENABLE(win->index);
 			data &= ~SHADOWCON_CHx_LOCAL_ENABLE(win->index);
 			writel(data, sfb->regs + SHADOWCON);
 		}
-		unregister_framebuffer(win->fbinfo);
+		if (win->registered)
+			unregister_framebuffer(win->fbinfo);
 		if (win->fbinfo->cmap.len)
 			fb_dealloc_cmap(&win->fbinfo->cmap);
 		s3c_fb_free_memory(sfb, win);
@@ -1272,6 +1275,7 @@ static int s3c_fb_probe_win(struct s3c_fb *sfb, unsigned int win_no,
 		return ret;
 	}
 
+	win->registered = true;
 	dev_info(sfb->dev, "window %d: fb %s\n", win_no, fbinfo->fix.id);
 
 	return 0;

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
-- 
2.43.0


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

end of thread, other threads:[~2026-11-18 18:17 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:22 [PATCH] fbdev: s3c-fb: Fix potential registration corruption on probe failure Guangshuo Li
2026-11-18 18:17 ` Helge Deller

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