[PATCH 11/24] Add rational_best_approximation()

Trent Piepho trent.piepho at igorinstitute.com
Wed Jun 2 11:25:29 PDT 2021


On Wed, Jun 2, 2021 at 3:05 AM Sascha Hauer <s.hauer at pengutronix.de> wrote:
>
> Import rational_best_approximation() from Linux. This is used by an
> upcoming update of the clk_fractional_divider code.

> +               if ((n2 > max_numerator) || (d2 > max_denominator)) {
> +                       unsigned long t = min((max_numerator - n0) / n1,
> +                                             (max_denominator - d0) / d1);
> +

There is a divide by zero bug in this version if the input is greater
than the largest value allowed or less than the smallest non-zero
value allowed.  I sent a patch to lkml for this a week ago,
https://lore.kernel.org/patchwork/patch/1436255/



More information about the barebox mailing list