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().

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

Reply via email to