From: Jiri Kosina Date: Tue, 23 Mar 2010 15:32:37 +0000 (+0100) Subject: HID: fix oops in gyration_event() X-Git-Tag: v2.6.33.3~109 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=7a48779f900760fb368efdef7e839b066527bb17;p=karo-tx-linux.git HID: fix oops in gyration_event() commit d8e4ebf8b603bdcd091540e6b5bddf0dec10d516 upstream. Fix oops caused by dereferencing field->hidinput in cases where the device hasn't been claimed by hid-input. Reported-by: Andreas Demmer Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/hid/hid-gyration.c b/drivers/hid/hid-gyration.c index cab13e8c7d29..62416e6baeca 100644 --- a/drivers/hid/hid-gyration.c +++ b/drivers/hid/hid-gyration.c @@ -53,10 +53,13 @@ static int gyration_input_mapping(struct hid_device *hdev, struct hid_input *hi, static int gyration_event(struct hid_device *hdev, struct hid_field *field, struct hid_usage *usage, __s32 value) { - struct input_dev *input = field->hidinput->input; + + if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput) + return 0; if ((usage->hid & HID_USAGE_PAGE) == HID_UP_GENDESK && (usage->hid & 0xff) == 0x82) { + struct input_dev *input = field->hidinput->input; input_event(input, usage->type, usage->code, 1); input_sync(input); input_event(input, usage->type, usage->code, 0);