]>
Commit | Line | Data |
---|---|---|
9659d8ac GKH |
1 | From d8e4ebf8b603bdcd091540e6b5bddf0dec10d516 Mon Sep 17 00:00:00 2001 |
2 | From: Jiri Kosina <jkosina@suse.cz> | |
3 | Date: Tue, 23 Mar 2010 16:32:37 +0100 | |
4 | Subject: HID: fix oops in gyration_event() | |
5 | ||
6 | From: Jiri Kosina <jkosina@suse.cz> | |
7 | ||
8 | commit d8e4ebf8b603bdcd091540e6b5bddf0dec10d516 upstream. | |
9 | ||
10 | Fix oops caused by dereferencing field->hidinput in cases where | |
11 | the device hasn't been claimed by hid-input. | |
12 | ||
13 | Reported-by: Andreas Demmer <mail@andreas-demmer.de> | |
14 | Signed-off-by: Jiri Kosina <jkosina@suse.cz> | |
15 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
16 | ||
17 | --- | |
18 | drivers/hid/hid-gyration.c | 5 ++++- | |
19 | 1 file changed, 4 insertions(+), 1 deletion(-) | |
20 | ||
21 | --- a/drivers/hid/hid-gyration.c | |
22 | +++ b/drivers/hid/hid-gyration.c | |
23 | @@ -53,10 +53,13 @@ static int gyration_input_mapping(struct | |
24 | static int gyration_event(struct hid_device *hdev, struct hid_field *field, | |
25 | struct hid_usage *usage, __s32 value) | |
26 | { | |
27 | - struct input_dev *input = field->hidinput->input; | |
28 | + | |
29 | + if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput) | |
30 | + return 0; | |
31 | ||
32 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_GENDESK && | |
33 | (usage->hid & 0xff) == 0x82) { | |
34 | + struct input_dev *input = field->hidinput->input; | |
35 | input_event(input, usage->type, usage->code, 1); | |
36 | input_sync(input); | |
37 | input_event(input, usage->type, usage->code, 0); |