HID: check for NULL field when setting values
authorKees Cook <keescook@chromium.org>
Wed, 28 Aug 2013 20:32:01 +0000 (22:32 +0200)
committerBadhri Jagan Sridharan <Badhri@google.com>
Fri, 11 Jul 2014 21:30:38 +0000 (14:30 -0700)
Defensively check that the field to be worked on is not NULL.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: stable@kernel.org
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-core.c

index eadcc85e5a6279998fcc16cfe50c88b0190b95d1..5b3e4cf7ca6b454381f224f796b1fbe8311ecd1c 100644 (file)
@@ -1212,7 +1212,12 @@ EXPORT_SYMBOL_GPL(hid_output_report);
 
 int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
 {
-       unsigned size = field->report_size;
+       unsigned size;
+
+       if (!field)
+               return -1;
+
+       size = field->report_size;
 
        hid_dump_input(field->report->device, field->usage + offset, value);