Skip to contentSkip to conversation

Fixes kernel panic with Null pointer in hid-appleir.c

PATCH In review Nicholas Krause 2 participants 2 messages Jun 20, 2014 – Jun 30, 2014 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fixes kernel panic with Null pointer in hid-appleir.c

In for loop of function appleir_input_configured we hit a Null pointer after the for loop due to array_size not being correct needs to be changed to input_dev->keycodemax.

---
 drivers/hid/hid-appleir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-appleir.c +1 -1
index 0e6a42d..ab0a702 100644
@@ -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 < ARRAY_SIZE(input_dev->keycodemax); i++)
 		set_bit(appleir->keymap[i], input_dev->keybit);
 	clear_bit(KEY_RESERVED, input_dev->keybit);
 }
Signature · 1 line
1.9.1
#1 lore raw
Quoted 14 lines · Nicholas Krause

In for loop of function appleir_input_configured we hit a Null pointer after the for loop due to array_size not being correct needs to be changed to input_dev->keycodemax.

---
 drivers/hid/hid-appleir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-appleir.c +0 -0
index 0e6a42d..ab0a702 100644

drivers/hid/hid-appleir.c static void appleir_input_configured(struct hid_device *hid, · line 275

Quoted 5 lines
drivers/hid/hid-appleir.c +1 -1
@@ -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 < ARRAY_SIZE(input_dev->keycodemax); i++)

Ugh, how is this supposed to work? input_dev->keycodemax is int, not array. I think you actually want sizeof(appleir->keymap) there.

Signature · 2 lines
Jiri Kosina
SUSE Labs