Re: [PATCH v3] drm/log: Fix division by zero when scale module parameter is 0

Jocelyn Falempe <[email protected]>
Newsgroups org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 30/07/2026 03:44, [email protected] wrote:
> From: Shixiong Ou <[email protected]>
> 
> 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 <[email protected]>

> 
> Signed-off-by: Shixiong Ou <[email protected]>
> ---
> 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
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.