From: Kees Cook Date: Wed, 28 Aug 2013 20:32:01 +0000 (+0200) Subject: HID: check for NULL field when setting values X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8bb7aacefb408f829835f3692dd34fab9801d86d;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git HID: check for NULL field when setting values commit be67b68d52fa28b9b721c47bb42068f0c1214855 upstream. Defensively check that the field to be worked on is not NULL. Signed-off-by: Kees Cook Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index eb202481fb09..ed626e01514b 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1156,7 +1156,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);