lkml.org 
[lkml]   [2008]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2.6.27-rc3] led: driver for LEDs on PCEngines ALIX.2 and ALIX.3 boards
Hi Andrew,

On Fri, Aug 22, 2008 at 11:51:50AM -0700, Andrew Morton wrote:
> On Tue, 19 Aug 2008 22:23:41 +0500
> Constantin Baranov <const@const.mimas.ru> wrote:
> > +static int __init alix_led_probe(struct platform_device *pdev)
> > +{
> > + int i;
> > + int ret = 0;
> > +
> > + for (i = 0; i < ARRAY_SIZE(alix_leds) && ret >= 0; i++)
> > + ret = led_classdev_register(&pdev->dev, &alix_leds[i].cdev);
> > +
> > + if (ret < 0) {
> > + for (i = i - 2; i >= 0; i--)
>
> this is off-by-one, surely.
>
> If we get here with i==1, we'll loop 4 billion times.

No we will not because i is signed. We'll simply not enter the loop.
However, the code looks suspicious and the reasoning behind i-2 isn't
quite clear.

Willy



\
 
 \ /
  Last update: 2008-08-22 21:47    [W:0.204 / U:0.536 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site