]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/panic: Fix divide by 0 if the screen width < font width
authorJocelyn Falempe <jfalempe@redhat.com>
Thu, 9 Oct 2025 12:24:52 +0000 (14:24 +0200)
committerJocelyn Falempe <jfalempe@redhat.com>
Tue, 21 Oct 2025 09:28:03 +0000 (11:28 +0200)
In the unlikely case that the screen is tiny, and smaller than the
font width, it leads to a divide by 0:

draw_line_with_wrap()
chars_per_row = sb->width / font->width = 0
line_wrap.len = line->len % chars_per_row;

This will trigger a divide by 0

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://lore.kernel.org/r/20251009122955.562888-6-jfalempe@redhat.com
Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
drivers/gpu/drm/drm_panic.c

index 69be9d835ccf199b392007e4b0267df9a2d75e6d..bc5158683b2b866b85e2328ec25beece77163e15 100644 (file)
@@ -523,7 +523,7 @@ static void draw_panic_static_kmsg(struct drm_scanout_buffer *sb)
        struct drm_panic_line line;
        int yoffset;
 
-       if (!font)
+       if (!font || font->width > sb->width)
                return;
 
        yoffset = sb->height - font->height - (sb->height % font->height) / 2;