Skip to content

Commit

Permalink
HID: fix oops in gyration_event()
Browse files Browse the repository at this point in the history
Fix oops caused by dereferencing field->hidinput in cases where
the device hasn't been claimed by hid-input.

Reported-by: Andreas Demmer <mail@andreas-demmer.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Jiri Kosina committed Mar 23, 2010
1 parent 3971047 commit d8e4ebf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/hid/hid-gyration.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d8e4ebf

Please sign in to comment.