* [PATCH 3/4] drm/log: Fix infinite loop when scale is too large for display
@ 2026-07-29 8:48 oushixiong1025
2026-07-29 15:18 ` Jocelyn Falempe
0 siblings, 1 reply; 2+ messages in thread
From: oushixiong1025 @ 2026-07-29 8:48 UTC (permalink / raw)
To: Jocelyn Falempe
Cc: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, dri-devel,
linux-kernel, Shixiong Ou
From: Shixiong Ou <oushixiong@kylinos.cn>
When scale is large enough that scaled_font exceeds the display
dimensions, rows or columns become 0. A columns value of 0 causes
an infinite loop in drm_log_draw_kmsg_record() because the loop
never decrements len.
Check for zero rows/columns in drm_log_setup_modeset() and return
an error, cleaning up the already allocated buffer to avoid a leak.
Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
---
drivers/gpu/drm/clients/drm_log.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/gpu/drm/clients/drm_log.c b/drivers/gpu/drm/clients/drm_log.c
index a04f651e8265..63577aeb705c 100644
--- a/drivers/gpu/drm/clients/drm_log.c
+++ b/drivers/gpu/drm/clients/drm_log.c
@@ -240,6 +240,12 @@ static int drm_log_setup_modeset(struct drm_client_dev *client,
scanout->scaled_font_w = scanout->font->width * scale;
scanout->rows = height / scanout->scaled_font_h;
scanout->columns = width / scanout->scaled_font_w;
+ if (!scanout->rows || !scanout->columns) {
+ drm_client_buffer_delete(scanout->buffer);
+ scanout->buffer = NULL;
+ mode_set->fb = NULL;
+ return -EINVAL;
+ }
scanout->front_color = drm_draw_color_from_xrgb8888(0xffffff, format);
scanout->prefix_color = drm_draw_color_from_xrgb8888(0x4e9a06, format);
return 0;
--
2.25.1
No virus found
Checked by Hillstone Network AntiVirus
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 3/4] drm/log: Fix infinite loop when scale is too large for display
2026-07-29 8:48 [PATCH 3/4] drm/log: Fix infinite loop when scale is too large for display oushixiong1025
@ 2026-07-29 15:18 ` Jocelyn Falempe
0 siblings, 0 replies; 2+ messages in thread
From: Jocelyn Falempe @ 2026-07-29 15:18 UTC (permalink / raw)
To: oushixiong1025
Cc: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, dri-devel,
linux-kernel, Shixiong Ou
On 29/07/2026 10:48, oushixiong1025@163.com wrote:
> From: Shixiong Ou <oushixiong@kylinos.cn>
>
> When scale is large enough that scaled_font exceeds the display
> dimensions, rows or columns become 0. A columns value of 0 causes
> an infinite loop in drm_log_draw_kmsg_record() because the loop
> never decrements len.
>
> Check for zero rows/columns in drm_log_setup_modeset() and return
> an error, cleaning up the already allocated buffer to avoid a leak.
Thanks, it looks good to me.
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
>
> Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
> ---
> drivers/gpu/drm/clients/drm_log.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/gpu/drm/clients/drm_log.c b/drivers/gpu/drm/clients/drm_log.c
> index a04f651e8265..63577aeb705c 100644
> --- a/drivers/gpu/drm/clients/drm_log.c
> +++ b/drivers/gpu/drm/clients/drm_log.c
> @@ -240,6 +240,12 @@ static int drm_log_setup_modeset(struct drm_client_dev *client,
> scanout->scaled_font_w = scanout->font->width * scale;
> scanout->rows = height / scanout->scaled_font_h;
> scanout->columns = width / scanout->scaled_font_w;
> + if (!scanout->rows || !scanout->columns) {
> + drm_client_buffer_delete(scanout->buffer);
> + scanout->buffer = NULL;
> + mode_set->fb = NULL;
> + return -EINVAL;
> + }
> scanout->front_color = drm_draw_color_from_xrgb8888(0xffffff, format);
> scanout->prefix_color = drm_draw_color_from_xrgb8888(0x4e9a06, format);
> return 0;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-29 15:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-29 8:48 [PATCH 3/4] drm/log: Fix infinite loop when scale is too large for display oushixiong1025
2026-07-29 15:18 ` Jocelyn Falempe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.