From: Jocelyn Falempe <jfalempe@redhat.com>
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>,
Jocelyn Falempe <jfalempe@redhat.com>,
Javier Martinez Canillas <javierm@redhat.com>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Cc: stable@vger.kernel.org
Subject: [PATCH 3/6] drm/panic: Fix qr_code, ensure vmargin is positive
Date: Thu, 9 Oct 2025 14:24:50 +0200 [thread overview]
Message-ID: <20251009122955.562888-4-jfalempe@redhat.com> (raw)
In-Reply-To: <20251009122955.562888-1-jfalempe@redhat.com>
Depending on qr_code size and screen size, the vertical margin can
be negative, that means there is not enough room to draw the qr_code.
So abort early, to avoid a segfault by trying to draw at negative
coordinates.
Fixes: cb5164ac43d0f ("drm/panic: Add a QR code panic screen")
Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
---
drivers/gpu/drm/drm_panic.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c
index 179cbf21f22d..281bb2dabf81 100644
--- a/drivers/gpu/drm/drm_panic.c
+++ b/drivers/gpu/drm/drm_panic.c
@@ -736,7 +736,10 @@ static int _draw_panic_static_qr_code(struct drm_scanout_buffer *sb)
pr_debug("QR width %d and scale %d\n", qr_width, scale);
r_qr_canvas = DRM_RECT_INIT(0, 0, qr_canvas_width * scale, qr_canvas_width * scale);
- v_margin = (sb->height - drm_rect_height(&r_qr_canvas) - drm_rect_height(&r_msg)) / 5;
+ v_margin = sb->height - drm_rect_height(&r_qr_canvas) - drm_rect_height(&r_msg);
+ if (v_margin < 0)
+ return -ENOSPC;
+ v_margin /= 5;
drm_rect_translate(&r_qr_canvas, (sb->width - r_qr_canvas.x2) / 2, 2 * v_margin);
r_qr = DRM_RECT_INIT(r_qr_canvas.x1 + QR_MARGIN * scale, r_qr_canvas.y1 + QR_MARGIN * scale,
--
2.51.0
next prev parent reply other threads:[~2025-10-09 12:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-09 12:24 [PATCH 0/6] drm/panic: Fixes found with kunit Jocelyn Falempe
2025-10-09 12:24 ` [PATCH 1/6] drm/panic: Fix drawing the logo on a small narrow screen Jocelyn Falempe
2025-10-14 7:32 ` Javier Martinez Canillas
2025-10-09 12:24 ` [PATCH 2/6] drm/panic: Fix overlap between qr code and logo Jocelyn Falempe
2025-10-14 7:32 ` Javier Martinez Canillas
2025-10-09 12:24 ` Jocelyn Falempe [this message]
2025-10-14 7:34 ` [PATCH 3/6] drm/panic: Fix qr_code, ensure vmargin is positive Javier Martinez Canillas
2025-10-09 12:24 ` [PATCH 4/6] drm/panic: Fix kmsg text drawing rectangle Jocelyn Falempe
2025-10-14 7:35 ` Javier Martinez Canillas
2025-10-09 12:24 ` [PATCH 5/6] drm/panic: Fix divide by 0 if the screen width < font width Jocelyn Falempe
2025-10-14 7:36 ` Javier Martinez Canillas
2025-10-09 12:24 ` [PATCH 6/6] drm/panic: Fix 24bit pixel crossing page boundaries Jocelyn Falempe
2025-10-14 7:37 ` Javier Martinez Canillas
2025-10-21 9:35 ` [PATCH 0/6] drm/panic: Fixes found with kunit Jocelyn Falempe
2025-10-21 11:24 ` Thomas Zimmermann
2025-10-21 12:32 ` Jocelyn Falempe
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=20251009122955.562888-4-jfalempe@redhat.com \
--to=jfalempe@redhat.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--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®