lkml.org 
[lkml]   [2013]   [Jun]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] thinkpad_acpi: return -NODEV while operating uninitialized LEDs
On Fri, Jun 07, 2013 at 10:53:50AM +0200, Bjørn Mork wrote:
> Adam Lee <adam.lee@canonical.com> writes:
>
> > --- a/drivers/platform/x86/thinkpad_acpi.c
> > +++ b/drivers/platform/x86/thinkpad_acpi.c
> > @@ -5401,9 +5401,12 @@ static int led_write(char *buf)
> > return -ENODEV;
> >
> > while ((cmd = next_cmd(&buf))) {
> > - if (sscanf(cmd, "%d", &led) != 1 || led < 0 || led > 15)
> > + if (sscanf(cmd, "%d", &led) != 1)
> > return -EINVAL;
> >
> > + if (!tpacpi_leds[led].led)
> > + return -ENODEV;
>
> This looks risky. Why did you remove the index sanity check? What will
> happen now if the input is e.g "-1" or "42"?
>
> BTW, the magic number 15 should probably be (TPACPI_LED_NUMLEDS - 1)
> instead.

Oh, good point! I was thinking led_init() already checked the index.

Will submit patch v2, thanks.

--
Regards,
Adam Lee
Hardware Enablement
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2013-06-07 15:42    [W:0.146 / U:1.360 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site