public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] auxdisplay: line-display: fix NULL dereference in linedisp_release
@ 2026-03-26 17:14 Guangshuo Li
  2026-03-26 19:18 ` Andy Shevchenko
  2026-03-27  8:10 ` Geert Uytterhoeven
  0 siblings, 2 replies; 5+ messages in thread
From: Guangshuo Li @ 2026-03-26 17:14 UTC (permalink / raw)
  To: Andy Shevchenko, Geert Uytterhoeven, Jean-François Lessard,
	Ingo Molnar, Thomas Gleixner, Guangshuo Li, linux-kernel
  Cc: stable

linedisp_release() currently retrieves the enclosing struct linedisp via
to_linedisp(). That lookup depends on the attachment list, but the
attachment may already have been removed before put_device() invokes the
release callback. This can happen in linedisp_unregister(), and can also
be reached from some linedisp_register() error paths.

In that case, to_linedisp() returns NULL and linedisp_release()
dereferences it while freeing the display resources.

The struct device released here is the embedded linedisp->dev used by
linedisp_register(), so retrieve the enclosing object directly with
container_of() instead.

Fixes: 66c93809487e ("auxdisplay: linedisp: encapsulate container_of usage within to_linedisp")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/auxdisplay/line-display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-display.c
index 4e22373fcc1a..e80e94262830 100644
--- a/drivers/auxdisplay/line-display.c
+++ b/drivers/auxdisplay/line-display.c
@@ -365,7 +365,7 @@ static DEFINE_IDA(linedisp_id);
 
 static void linedisp_release(struct device *dev)
 {
-	struct linedisp *linedisp = to_linedisp(dev);
+	struct linedisp *linedisp = container_of(dev, struct linedisp, dev);
 
 	kfree(linedisp->map);
 	kfree(linedisp->message);
-- 
2.43.0


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

end of thread, other threads:[~2026-03-27  8:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-26 17:14 [PATCH] auxdisplay: line-display: fix NULL dereference in linedisp_release Guangshuo Li
2026-03-26 19:18 ` Andy Shevchenko
2026-03-27  4:28   ` Guangshuo Li
2026-03-27  8:10 ` Geert Uytterhoeven
2026-03-27  8:54   ` Andy Shevchenko

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