drm/panic: Fix the potential loop that causes kmsg to not display correctly
Subsystems (3)
PATCH 1/1 drm/panic: Fix the potential loop that causes kmsg to not display correctly
From: luyuantao <[email protected]>
When kmsg_buf completes drawing the screen and yoffset is less than 0, kmsg_dump_get_buffer continues to obtain the buffer. This potential loop may cause panic_flush not to be executed immediately or even not to be executed at all, resulting in a garbled screen display instead of normal logs
So, the loop should be exited immediately after drawing kmsg_buf
--- drivers/gpu/drm/drm_panic.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_panic.c +3 -0
@@ -592,6 +592,9 @@ static void draw_panic_static_kmsg(struct drm_scanout_buffer *sb) end = start; start--; } + +if (yoffset <0 ) +break ; } }
Signature · 1 line
2.27.0
Jocelyn Falempe
maintainerQuoted 8 lines · On 26/01/2026 06:40, luyuantao01 wrote:
From: luyuantao <[email protected]>
When
kmsg_bufcompletes drawing the screen and yoffset is less than 0,kmsg_dump_get_buffercontinues to obtain the buffer. This potential loop may causepanic_flushnot to be executed immediately or even not to be executed at all, resulting in a garbled screen display instead of normal logsSo, the loop should be exited immediately after drawing
kmsg_buf
You're right, the loop should stop when the screen is filled.
I would prefer writing it like this:
while (yoffset >= 0 && kmsg_dump_get_buffer(&iter, false, kmsg_buf, sizeof(kmsg_buf), &kmsg_len)) {
Can you send a v2 with this changed?
Best regards,
Signature · 1 line
Jocelyn
Quoted 20 lines
Signed-off-by luyuantao <[email protected]>--- drivers/gpu/drm/drm_panic.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/drm_panic.c +3
-0@@ -592,6 +592,9 @@ static void draw_panic_static_kmsg(struct drm_scanout_buffer *sb) end = start; start--; } + +if (yoffset <0 ) +break ; } }
PATCH v2 1/1 drm/panic: Fix the potential loop that causes kmsg to not display correctly
In reply to luyuantao01From: luyuantao <[email protected]>
When kmsg_buf completes drawing the screen and yoffset is less than 0, kmsg_dump_get_buffer continues to obtain the buffer. This potential loop may cause panic_flush not to be executed immediately or even not to be executed at all, resulting in a garbled screen display instead of normal logs
So, the loop should be exited immediately after drawing kmsg_buf
--- drivers/gpu/drm/drm_panic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_panic.c +2 -1
@@ -574,7 +574,8 @@ static void draw_panic_static_kmsg(struct drm_scanout_buffer *sb)drm_panic_fill (sb, &r_screen, bg_color);kmsg_dump_rewind (&iter); -while (kmsg_dump_get_buffer (&iter, false, kmsg_buf,sizeof (kmsg_buf), &kmsg_len)) { +while (yoffset >=0 &&kmsg_dump_get_buffer (&iter, false, kmsg_buf, +sizeof (kmsg_buf), &kmsg_len)) {char *start;char *end;
Signature · 1 line
2.27.0
Quoted 8 lines · On 26/01/2026 11:07, luyuantao01 wrote:
From: luyuantao <[email protected]>
When
kmsg_bufcompletes drawing the screen and yoffset is less than 0,kmsg_dump_get_buffercontinues to obtain the buffer. This potential loop may causepanic_flushnot to be executed immediately or even not to be executed at all, resulting in a garbled screen display instead of normal logsSo, the loop should be exited immediately after drawing
kmsg_buf
Thanks, for sending a v2.
I will push it to drm-misc-next in a few days if no other comment.
Quoted 20 lines
Signed-off-by luyuantao <[email protected]>--- drivers/gpu/drm/drm_panic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_panic.c +2
-1@@ -574,7 +574,8 @@ static void draw_panic_static_kmsg(struct drm_scanout_buffer *sb)drm_panic_fill (sb, &r_screen, bg_color);kmsg_dump_rewind (&iter); -while (kmsg_dump_get_buffer (&iter, false, kmsg_buf,sizeof (kmsg_buf), &kmsg_len)) { +while (yoffset >=0 &&kmsg_dump_get_buffer (&iter, false, kmsg_buf, +sizeof (kmsg_buf), &kmsg_len)) {char *start;char *end;
Quoted 11 lines · luyuantao01 <[email protected]> writes:
From: luyuantao <[email protected]>
When
kmsg_bufcompletes drawing the screen and yoffset is less than 0,kmsg_dump_get_buffercontinues to obtain the buffer. This potential loop may causepanic_flushnot to be executed immediately or even not to be executed at all, resulting in a garbled screen display instead of normal logsSo, the loop should be exited immediately after drawing
kmsg_bufSigned-off-by luyuantao <[email protected]>---
Makes sense to me.
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat