All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [patch] dell-laptop: fix kbd_timeout handling
  2014-12-03 10:01 ` [patch] dell-laptop: fix kbd_timeout handling Dan Carpenter
@ 2014-12-03  7:33   ` Darren Hart
  2014-12-04  8:30     ` Dan Carpenter
  2014-12-04  9:42     ` Pali Rohár
  0 siblings, 2 replies; 5+ messages in thread
From: Darren Hart @ 2014-12-03  7:33 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Pali Rohár, platform-driver-x86, Matthew Garrett, kbuild,
	Gabriele Mazzotta

On Wed, Dec 03, 2014 at 01:01:59PM +0300, Dan Carpenter wrote:
> The original code had a static checker warning:
> 
> 	drivers/platform/x86/dell-laptop.c:1389 kbd_led_timeout_store()
> 	warn: this array is probably non-NULL. 'quirks->kbd_timeouts'
> 
> This warning does indicate a bug.  I have added a .needs_kbd_timeouts
> flag which is true if the .kbd_timeouts[] array has been declared.
> Otherwise, in the original code the quirk_dell_vostro_v130 struct didn't
> have .kbd_timeouts[] declared so the loop:
> 
> 	for (i = 0; quirks->kbd_timeouts[i] != -1; i++) {
> 
> Would have read beyond the end of the struct with unpredictable results.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>


Thanks Dan,

Pali, any objections?

Dan, any objection to Pali rolling this into another revision? No point in
introducing the bug to next and mainline.

Thanks,

-- 
Darren Hart
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [patch] dell-laptop: fix kbd_timeout handling
       [not found] <1417597233.14672.2.camel@Pali-Nokia-N900>
@ 2014-12-03 10:01 ` Dan Carpenter
  2014-12-03  7:33   ` Darren Hart
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2014-12-03 10:01 UTC (permalink / raw)
  To: Pali Rohár, Darren Hart
  Cc: Gabriele Mazzotta, Matthew Garrett, kbuild, platform-driver-x86

The original code had a static checker warning:

	drivers/platform/x86/dell-laptop.c:1389 kbd_led_timeout_store()
	warn: this array is probably non-NULL. 'quirks->kbd_timeouts'

This warning does indicate a bug.  I have added a .needs_kbd_timeouts
flag which is true if the .kbd_timeouts[] array has been declared.
Otherwise, in the original code the quirk_dell_vostro_v130 struct didn't
have .kbd_timeouts[] declared so the loop:

	for (i = 0; quirks->kbd_timeouts[i] != -1; i++) {

Would have read beyond the end of the struct with unpredictable results.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This fixes a patch in Darren Hart's tree and it may not have yet reached
linux-next.  The patch is 167e24aa8adf ('platform: x86: dell-laptop: Add
support for keyboard backlight')

diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 46e9037..a311375 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -72,6 +72,7 @@ struct calling_interface_structure {
 struct quirk_entry {
 	u8 touchpad_led;
 
+	int needs_kbd_timeouts;
 	/* Ordered list of timeouts expressed in seconds.
 	 * The list must end with -1 */
 	int kbd_timeouts[];
@@ -90,6 +91,7 @@ static int __init dmi_matched(const struct dmi_system_id *dmi)
 }
 
 static struct quirk_entry quirk_dell_xps13_9333 = {
+	.needs_kbd_timeouts = 1,
 	.kbd_timeouts = { 0, 5, 15, 60, 5*60, 15*60, -1 },
 };
 
@@ -1386,7 +1388,7 @@ static ssize_t kbd_led_timeout_store(struct device *dev,
 		return -EINVAL;
 	}
 
-	if (quirks && quirks->kbd_timeouts)
+	if (quirks && quirks->needs_kbd_timeouts)
 		convert = true;
 
 	if (convert) {
@@ -1401,7 +1403,7 @@ static ssize_t kbd_led_timeout_store(struct device *dev,
 			unit = KBD_TIMEOUT_SECONDS;
 		}
 
-		if (quirks && quirks->kbd_timeouts) {
+		if (quirks && quirks->needs_kbd_timeouts) {
 			for (i = 0; quirks->kbd_timeouts[i] != -1; i++) {
 				if (value <= quirks->kbd_timeouts[i]) {
 					value = quirks->kbd_timeouts[i];

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch] dell-laptop: fix kbd_timeout handling
  2014-12-03  7:33   ` Darren Hart
@ 2014-12-04  8:30     ` Dan Carpenter
  2014-12-04  9:42     ` Pali Rohár
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2014-12-04  8:30 UTC (permalink / raw)
  To: Darren Hart
  Cc: Gabriele Mazzotta, Matthew Garrett, kbuild, platform-driver-x86,
	Pali Rohár

On Tue, Dec 02, 2014 at 11:33:25PM -0800, Darren Hart wrote:
>
> Dan, any objection to Pali rolling this into another revision?

No problem, that's fine.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] dell-laptop: fix kbd_timeout handling
  2014-12-03  7:33   ` Darren Hart
  2014-12-04  8:30     ` Dan Carpenter
@ 2014-12-04  9:42     ` Pali Rohár
  2014-12-04 10:58       ` Gabriele Mazzotta
  1 sibling, 1 reply; 5+ messages in thread
From: Pali Rohár @ 2014-12-04  9:42 UTC (permalink / raw)
  To: Darren Hart
  Cc: Dan Carpenter, platform-driver-x86, Matthew Garrett, kbuild,
	Gabriele Mazzotta

[-- Attachment #1: Type: Text/Plain, Size: 1191 bytes --]

On Wednesday 03 December 2014 08:33:25 Darren Hart wrote:
> On Wed, Dec 03, 2014 at 01:01:59PM +0300, Dan Carpenter wrote:
> > The original code had a static checker warning:
> > 	drivers/platform/x86/dell-laptop.c:1389
> > 	kbd_led_timeout_store() warn: this array is probably
> > 	non-NULL. 'quirks->kbd_timeouts'
> > 
> > This warning does indicate a bug.  I have added a
> > .needs_kbd_timeouts flag which is true if the
> > .kbd_timeouts[] array has been declared. Otherwise, in the
> > original code the quirk_dell_vostro_v130 struct didn't
> > 
> > have .kbd_timeouts[] declared so the loop:
> > 	for (i = 0; quirks->kbd_timeouts[i] != -1; i++) {
> > 
> > Would have read beyond the end of the struct with
> > unpredictable results.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Thanks Dan,
> 
> Pali, any objections?
> 
> Dan, any objection to Pali rolling this into another revision?
> No point in introducing the bug to next and mainline.
> 
> Thanks,

No problem from my side. This quirks code was done by Gabriele to 
fix BIOS problems on some laptops.

Gabriele, any objections?

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] dell-laptop: fix kbd_timeout handling
  2014-12-04  9:42     ` Pali Rohár
@ 2014-12-04 10:58       ` Gabriele Mazzotta
  0 siblings, 0 replies; 5+ messages in thread
From: Gabriele Mazzotta @ 2014-12-04 10:58 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Darren Hart, Dan Carpenter, platform-driver-x86, Matthew Garrett,
	kbuild

On Thursday 04 December 2014 10:42:37 Pali Rohár wrote:
> On Wednesday 03 December 2014 08:33:25 Darren Hart wrote:
> > On Wed, Dec 03, 2014 at 01:01:59PM +0300, Dan Carpenter wrote:
> > > The original code had a static checker warning:
> > > 	drivers/platform/x86/dell-laptop.c:1389
> > > 	kbd_led_timeout_store() warn: this array is probably
> > > 	non-NULL. 'quirks->kbd_timeouts'
> > > 
> > > This warning does indicate a bug.  I have added a
> > > .needs_kbd_timeouts flag which is true if the
> > > .kbd_timeouts[] array has been declared. Otherwise, in the
> > > original code the quirk_dell_vostro_v130 struct didn't
> > > 
> > > have .kbd_timeouts[] declared so the loop:
> > > 	for (i = 0; quirks->kbd_timeouts[i] != -1; i++) {
> > > 
> > > Would have read beyond the end of the struct with
> > > unpredictable results.
> > > 
> > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > Thanks Dan,
> > 
> > Pali, any objections?
> > 
> > Dan, any objection to Pali rolling this into another revision?
> > No point in introducing the bug to next and mainline.
> > 
> > Thanks,
> 
> No problem from my side. This quirks code was done by Gabriele to
> fix BIOS problems on some laptops.
> 
> Gabriele, any objections?

No objections.

Gabriele.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-12-04 10:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1417597233.14672.2.camel@Pali-Nokia-N900>
2014-12-03 10:01 ` [patch] dell-laptop: fix kbd_timeout handling Dan Carpenter
2014-12-03  7:33   ` Darren Hart
2014-12-04  8:30     ` Dan Carpenter
2014-12-04  9:42     ` Pali Rohár
2014-12-04 10:58       ` Gabriele Mazzotta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.