* [PATCH v3] drm/log: Fix division by zero when scale module parameter is 0
@ 2026-07-30 1:44 oushixiong1025
2026-07-31 7:19 ` Jocelyn Falempe
0 siblings, 1 reply; 2+ messages in thread
From: oushixiong1025 @ 2026-07-30 1:44 UTC (permalink / raw)
To: Jocelyn Falempe
Cc: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Jani Nikula,
dri-devel, linux-kernel, Shixiong Ou
From: Shixiong Ou <oushixiong@kylinos.cn>
The scale module parameter can be set to 0 via kernel command line.
When scale is 0, scaled_font_h and scaled_font_w become 0, causing
a division by zero in the rows/columns calculation.
Since the scale module parameter is read-only (0444 permissions), it
cannot be changed at runtime via sysfs. Clamp it to 1 once in
drm_log_register().
Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
---
v2->v3:
Clamp scale once in drm_log_register() instead of introducing a
drm_log_scale() helper, since scale is read-only at runtime.
v1->v2:
Introduce a drm_log_scale() helper.
diff --git a/drivers/gpu/drm/clients/drm_log.c b/drivers/gpu/drm/clients/drm_log.c
index 294b3be1a6b3..46004abd4e61 100644
--- a/drivers/gpu/drm/clients/drm_log.c
+++ b/drivers/gpu/drm/clients/drm_log.c
@@ -424,6 +424,9 @@ void drm_log_register(struct drm_device *dev)
{
struct drm_log *new;
+ if (!scale)
+ scale = 1;
+
new = kzalloc_obj(*new);
if (!new)
goto err_warn;
--
2.25.1
No virus found
Checked by Hillstone Network AntiVirus
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v3] drm/log: Fix division by zero when scale module parameter is 0
2026-07-30 1:44 [PATCH v3] drm/log: Fix division by zero when scale module parameter is 0 oushixiong1025
@ 2026-07-31 7:19 ` Jocelyn Falempe
0 siblings, 0 replies; 2+ messages in thread
From: Jocelyn Falempe @ 2026-07-31 7:19 UTC (permalink / raw)
To: oushixiong1025
Cc: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Jani Nikula,
dri-devel, linux-kernel, Shixiong Ou
On 30/07/2026 03:44, oushixiong1025@163.com wrote:
> From: Shixiong Ou <oushixiong@kylinos.cn>
>
> The scale module parameter can be set to 0 via kernel command line.
> When scale is 0, scaled_font_h and scaled_font_w become 0, causing
> a division by zero in the rows/columns calculation.
>
> Since the scale module parameter is read-only (0444 permissions), it
> cannot be changed at runtime via sysfs. Clamp it to 1 once in
> drm_log_register().
Thanks, it looks good to me
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
>
> Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
> ---
> v2->v3:
> Clamp scale once in drm_log_register() instead of introducing a
> drm_log_scale() helper, since scale is read-only at runtime.
>
> v1->v2:
> Introduce a drm_log_scale() helper.
>
> diff --git a/drivers/gpu/drm/clients/drm_log.c b/drivers/gpu/drm/clients/drm_log.c
> index 294b3be1a6b3..46004abd4e61 100644
> --- a/drivers/gpu/drm/clients/drm_log.c
> +++ b/drivers/gpu/drm/clients/drm_log.c
> @@ -424,6 +424,9 @@ void drm_log_register(struct drm_device *dev)
> {
> struct drm_log *new;
>
> + if (!scale)
> + scale = 1;
> +
> new = kzalloc_obj(*new);
> if (!new)
> goto err_warn;
> --
> 2.25.1
>
> No virus found
> Checked by Hillstone Network AntiVirus
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-31 7:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-30 1:44 [PATCH v3] drm/log: Fix division by zero when scale module parameter is 0 oushixiong1025
2026-07-31 7:19 ` Jocelyn Falempe
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®