[PATCH] net: ethernet: ti: Prevent divide-by-zero in cpts_calc_mult_shift()

Vadim Fedorenko vadim.fedorenko at linux.dev
Thu Aug 28 06:01:23 PDT 2025


On 28/08/2025 13:38, æå¦å© wrote:
> Hi, Vadim
> 
> Vadim Fedorenko <vadim.fedorenko at linux.dev> 于2025年8月28日周四 20:06写道:
>>
>> On 28/08/2025 10:22, Miaoqian Lin wrote:
>>> cpts_calc_mult_shift() has a potential divide-by-zero in this line:
>>>
>>>           do_div(maxsec, freq);
>>>
>>> due to the fact that clk_get_rate() can return zero in certain error
>>> conditions.
>>
>> Have you seen this happening in the real environment, or is it just
>> analysis of the code? I don't see a reason for these "certain error
>> conditions" to happen...
> 
> This is from code analysis, not from real environment.
> The !CONFIG_HAVE_CLK version of clk_get_rate() returns zero.
> With CONFIG_COMPILE_TEST && !CONFIG_HAVE_CLK could have the problem.
> This may be theoretical.

!CONFIG_HAVE_CLK will have cpts_create() doing nothing as defined in
cpts.h and it means the patch fixes impossible scenario.

NAck




More information about the Linux-mediatek mailing list