Re: [PATCH v2] drm/log: Fix division by zero when scale module parameter is 0
From: Jani Nikula
Date: Wed Jul 29 2026 - 11:30:50 EST
On Wed, 29 Jul 2026, Jocelyn Falempe <jfalempe@xxxxxxxxxx> wrote:
> On 29/07/2026 12:58, oushixiong1025@xxxxxxx wrote:
>> From: Shixiong Ou <oushixiong@xxxxxxxxxx>
>>
>> The scale module parameter can be set to 0 via kernel command line or
>> sysfs. When scale is 0, scaled_font_h and scaled_font_w become 0,
>> causing a division by zero in the rows/columns calculation.
>>
>> Introduce a drm_log_scale() helper that returns scale ?: 1, and use it
>> at all read sites. This avoids a race that a setter-based clamp would
>> have between param_set_uint() and the subsequent check, where another
>> CPU could observe scale == 0.
>
> The scale module parameter is read only (that's the meaning of 0444 in
> module_param()) so it can't be set by sysfs, or change at runtime.
>
> So this check can be done only once in drm_log_register().
Oops, missed this in my review completely, thanks!
--
Jani Nikula, Intel