lkml.org 
[lkml]   [2014]   [Jul]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] hid-appleir: Fix kernel panic due to null pointer
On Tue, Jul 01, 2014 at 08:39:06AM +0200, Jiri Kosina wrote:
> On Mon, 30 Jun 2014, Nicholas Krause wrote:
>
> > Fixes a null pointer in appleir_input_configured due to reading
> > into wrong size array. Changed the variable to input_dev->keycodemax.
>
> This is a stale changelog from the previous buggy version.
>
> > Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> > ---
> > drivers/hid/hid-appleir.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/hid/hid-appleir.c b/drivers/hid/hid-appleir.c
> > index 0e6a42d..cc02df4 100644
> > --- a/drivers/hid/hid-appleir.c
> > +++ b/drivers/hid/hid-appleir.c
> > @@ -272,7 +272,7 @@ static void appleir_input_configured(struct hid_device *hid,
> > input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
> >
> > memcpy(appleir->keymap, appleir_key_table, sizeof(appleir->keymap));
> > - for (i = 0; i < ARRAY_SIZE(appleir_key_table); i++)
> > + for (i = 0; i < appleir->keymap; i++)
>
> This is wrong. appleir->keymap is an array, and you want to count its
> elements.
>

But where the claim of 'null pointer' is coming from (or reading/writing
past the array for that matter)?

Replacing appleir_key_table with appleir->keymap is a noop anyway
because:
unsigned short keymap[ARRAY_SIZE(appleir_key_table)];

although one may argue is slightly nicer since it is used in memcpy line
earlier.
--
Mateusz Guzik


\
 
 \ /
  Last update: 2014-07-01 09:21    [W:0.048 / U:1.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site