diff options
| author | Rafi Rubin <rafi@seas.upenn.edu> | 2011-03-08 00:24:29 -0500 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2011-03-22 09:24:24 +0100 |
| commit | 3d166aa8bdcbf7cc6ee4f0cfabc4eadf66cd4afa (patch) | |
| tree | d0ba7adbd8bfadfd6b3d10521017ed818c6b928e /usr/src/dkms_source_tree/hid-ntrig.c | |
| parent | 4a5a274bbed9df7acd462a9a02d8a156b8742b12 (diff) | |
HID: ntrig don't dereference unclaimed hidinput
Check before dereferencing field->hidinput to fix a reported invalid
deference bug.
Signed-off-by: Rafi Rubin <rafi@seas.upenn.edu>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'usr/src/dkms_source_tree/hid-ntrig.c')
| -rw-r--r-- | usr/src/dkms_source_tree/hid-ntrig.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/usr/src/dkms_source_tree/hid-ntrig.c b/usr/src/dkms_source_tree/hid-ntrig.c index 0fab58b..9e6b91e 100644 --- a/usr/src/dkms_source_tree/hid-ntrig.c +++ b/usr/src/dkms_source_tree/hid-ntrig.c | |||
| @@ -332,8 +332,19 @@ static void report_frame(struct input_dev *input, struct ntrig_data *nd) | |||
| 332 | static int ntrig_event (struct hid_device *hid, struct hid_field *field, | 332 | static int ntrig_event (struct hid_device *hid, struct hid_field *field, |
| 333 | struct hid_usage *usage, __s32 value) | 333 | struct hid_usage *usage, __s32 value) |
| 334 | { | 334 | { |
| 335 | struct input_dev *input = field->hidinput->input; | ||
| 336 | struct ntrig_data *nd = hid_get_drvdata(hid); | 335 | struct ntrig_data *nd = hid_get_drvdata(hid); |
| 336 | struct input_dev *input; | ||
| 337 | |||
| 338 | /* Skip processing if not a claimed input */ | ||
| 339 | if (!(hid->claimed & HID_CLAIMED_INPUT)) | ||
| 340 | goto not_claimed_input; | ||
| 341 | |||
| 342 | /* This function is being called before the structures are fully | ||
| 343 | * initialized */ | ||
| 344 | if(!(field->hidinput && field->hidinput->input)) | ||
| 345 | return -EINVAL; | ||
| 346 | |||
| 347 | input = field->hidinput->input; | ||
| 337 | 348 | ||
| 338 | /* No special handling needed for the pen */ | 349 | /* No special handling needed for the pen */ |
| 339 | if (field->application == HID_DG_PEN) | 350 | if (field->application == HID_DG_PEN) |
| @@ -377,6 +388,8 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field, | |||
| 377 | } | 388 | } |
| 378 | } | 389 | } |
| 379 | 390 | ||
| 391 | not_claimed_input: | ||
| 392 | |||
| 380 | /* we have handled the hidinput part, now remains hiddev */ | 393 | /* we have handled the hidinput part, now remains hiddev */ |
| 381 | if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_hid_event) | 394 | if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_hid_event) |
| 382 | hid->hiddev_hid_event(hid, field, usage, value); | 395 | hid->hiddev_hid_event(hid, field, usage, value); |
