Re: [PATCH 1/3] thinkpad_acpi: return -NODEV while operating uninitialized LEDs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 07, 2013 at 10:53:50AM +0200, Bjørn Mork wrote:
> Adam Lee <adam.lee@xxxxxxxxxxxxx> 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

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
ibm-acpi-devel mailing list
ibm-acpi-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel





[Index of Archives]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Photo]     [Yosemite Photos]     [Yosemite Advice]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux