mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/gud: fix potential divide error due to optimisation
@ 2026-11-17 14:17 Ruben Wauters
  2026-11-17 14:27 ` Thomas Zimmermann
  0 siblings, 1 reply; 2+ messages in thread
From: Ruben Wauters @ 2026-11-17 14:17 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter
  Cc: Ruben Wauters, dri-devel, linux-kernel

Compilers can potentially optmise the read of gdrm->stats_actual_length
to two separate reads. As flagged by sashiko, when the rect is flushed
the stats_actual_length can reset to zero. If this was to occur between
the two reads, the divide error can still be triggered (albeit rarely).

Fix this by adding a READ_ONCE around the gdrm->stats_actual_length

Fixes: 431c2dffd2b7 ("drm/gud: avoid divide error in gud_stats_debugfs")
Signed-off-by: Ruben Wauters <ruben.wauters@linux.dev>
---
 drivers/gpu/drm/gud/gud_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/gud/gud_drv.c b/drivers/gpu/drm/gud/gud_drv.c
index cec5d64e152b..4854b30ea5ba 100644
--- a/drivers/gpu/drm/gud/gud_drv.c
+++ b/drivers/gpu/drm/gud/gud_drv.c
@@ -329,7 +329,7 @@ static int gud_stats_debugfs(struct seq_file *m, void *data)
 	seq_puts(m, "\n");
 
 	if (gdrm->compression) {
-		u64 actual_length = gdrm->stats_actual_length;
+		u64 actual_length = READ_ONCE(gdrm->stats_actual_length);
 		u64 remainder;
 		u64 ratio, ratio_frac;
 
-- 
2.56.1


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

end of thread, other threads:[~2026-11-17 14:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 14:17 [PATCH] drm/gud: fix potential divide error due to optimisation Ruben Wauters
2026-11-17 14:27 ` Thomas Zimmermann

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®