[PATCH] lm8333: Fix check ordering

Subsystems: input (keyboard, mouse, joystick, touchscreen) drivers, the rest

STALE5195d

2 messages, 2 authors, 2012-06-27 · open the first message on its own page

[PATCH] lm8333: Fix check ordering

From: Alan Cox <hidden>
Date: 2012-06-27 10:46:08

From: Alan Cox <redacted>

Fix harmless reference off end of array

Reported-by: <redacted>
Resolves-bug: https://bugzilla.kernel.org/show_bug.cgi?43861
Signed-off-by: Alan Cox <redacted>
---

 drivers/input/keyboard/lm8333.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard/lm8333.c
index ca168a6..081fd9e 100644
--- a/drivers/input/keyboard/lm8333.c
+++ b/drivers/input/keyboard/lm8333.c
@@ -91,7 +91,7 @@ static void lm8333_key_handler(struct lm8333 *lm8333)
 		return;
 	}
 
-	for (i = 0; keys[i] && i < LM8333_FIFO_TRANSFER_SIZE; i++) {
+	for (i = 0; i < LM8333_FIFO_TRANSFER_SIZE && keys[i]; i++) {
 		pressed = keys[i] & 0x80;
 		code = keys[i] & 0x7f;
 

Re: [PATCH] lm8333: Fix check ordering

From: Jiri Kosina <hidden>
Date: 2012-06-27 15:36:12

On Wed, 27 Jun 2012, Alan Cox wrote:
quoted hunk
From: Alan Cox <redacted>

Fix harmless reference off end of array

Reported-by: <redacted>
Resolves-bug: https://bugzilla.kernel.org/show_bug.cgi?43861
Signed-off-by: Alan Cox <redacted>
---

 drivers/input/keyboard/lm8333.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard/lm8333.c
index ca168a6..081fd9e 100644
--- a/drivers/input/keyboard/lm8333.c
+++ b/drivers/input/keyboard/lm8333.c
@@ -91,7 +91,7 @@ static void lm8333_key_handler(struct lm8333 *lm8333)
 		return;
 	}
 
-	for (i = 0; keys[i] && i < LM8333_FIFO_TRANSFER_SIZE; i++) {
+	for (i = 0; i < LM8333_FIFO_TRANSFER_SIZE && keys[i]; i++) {
 		pressed = keys[i] & 0x80;
 		code = keys[i] & 0x7f;
 
Applied to trivial, thanks Alan.

-- 
Jiri Kosina
SUSE Labs
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help