diff mbox

lm8333: Fix check ordering

Message ID 20120704145653.7910.26502.stgit@localhost.localdomain (mailing list archive)
State New, archived
Headers show

Commit Message

Alan Cox July 4, 2012, 2:57 p.m. UTC
From: Alan Cox <alan@linux.intel.com>

Fix harmless reference off end of array

Reported-by: <dcb314@hotmail.com>
Resolves-bug: https://bugzilla.kernel.org/show_bug.cgi?43861
Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/input/keyboard/lm8333.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Dmitry Torokhov July 4, 2012, 8:05 p.m. UTC | #1
Hi Alan,

On Wed, Jul 04, 2012 at 03:57:00PM +0100, Alan Cox wrote:
> From: Alan Cox <alan@linux.intel.com>
> 
> Fix harmless reference off end of array
> 
> Reported-by: <dcb314@hotmail.com>
> Resolves-bug: https://bugzilla.kernel.org/show_bug.cgi?43861
> Signed-off-by: Alan Cox <alan@linux.intel.com>
> ---
> 
>  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;
>  
> 

I believe Jiri has already queued this through trivial tree...

Thanks.
Jiri Kosina July 4, 2012, 9:45 p.m. UTC | #2
On Wed, 4 Jul 2012, Dmitry Torokhov wrote:

> > From: Alan Cox <alan@linux.intel.com>
> > 
> > Fix harmless reference off end of array
> > 
> > Reported-by: <dcb314@hotmail.com>
> > Resolves-bug: https://bugzilla.kernel.org/show_bug.cgi?43861
> > Signed-off-by: Alan Cox <alan@linux.intel.com>
> > ---
> > 
> >  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;
> >  
> > 
> 
> I believe Jiri has already queued this through trivial tree...

Yup, it's in -next as 954bd6d1c. Thanks,
diff mbox

Patch

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;