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

林妙倩 linmq006 at gmail.com
Thu Aug 28 05:38:20 PDT 2025


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.



More information about the Linux-mediatek mailing list