[Cake] [PATCH] sch_cake: avoid possible divide by zero in cake_enqueue()

Jonathan Morton chromatix99 at gmail.com
Thu Jan 2 16:58:02 EST 2020


> On 2 Jan, 2020, at 11:21 am, Wen Yang <wenyang at linux.alibaba.com> wrote:
> 
> The variables 'window_interval' is u64 and do_div()
> truncates it to 32 bits, which means it can test
> non-zero and be truncated to zero for division.
> The unit of window_interval is nanoseconds,
> so its lower 32-bit is relatively easy to exceed.
> Fix this issue by using div64_u64() instead.

That might actually explain a few things.  I approve.

Honestly the *correct* fix is for the compiler to implement division in a way that doesn't require substituting it with function calls.  As this shows, it's error-prone to do this manually.

 - Jonathan Morton


More information about the Cake mailing list