[PATCH 11/24] Add rational_best_approximation()

Sascha Hauer s.hauer at pengutronix.de
Mon Jun 7 04:22:45 PDT 2021


On Wed, Jun 02, 2021 at 11:25:29AM -0700, Trent Piepho wrote:
> 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/

I applies that on top of the series.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list