From: Ruben Wauters <ruben.wauters@linux.dev>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: Ruben Wauters <ruben.wauters@linux.dev>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH] drm/gud: fix potential divide error due to optimisation
Date: Tue, 17 Nov 2026 14:17:51 +0000 [thread overview]
Message-ID: <20261117141943.10540-1-ruben.wauters@linux.dev> (raw)
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
next reply other threads:[~2026-11-17 14:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 14:17 Ruben Wauters [this message]
2026-11-17 14:27 ` Thomas Zimmermann
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=20261117141943.10540-1-ruben.wauters@linux.dev \
--to=ruben.wauters@linux.dev \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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®