]> git.itanic.dy.fi Git - linux-stable/commitdiff
HID: check for NULL field when setting values
authorKees Cook <keescook@chromium.org>
Wed, 28 Aug 2013 20:32:01 +0000 (22:32 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Sep 2013 00:15:49 +0000 (17:15 -0700)
commit be67b68d52fa28b9b721c47bb42068f0c1214855 upstream.

Defensively check that the field to be worked on is not NULL.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hid/hid-core.c

index 228c8495e97f2dfc4226b2d54acb3088da343182..ab59fdf06230dcef4e073b01811b50caf2954408 100644 (file)
@@ -999,7 +999,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);