From: Kees Cook Date: Wed, 28 Aug 2013 20:32:01 +0000 (+0200) Subject: HID: check for NULL field when setting values X-Git-Tag: firefly_0821_release~4090^2~284 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=58c62d4474fbeda42851553a546e5cb860a036ea;p=firefly-linux-kernel-4.4.55.git HID: check for NULL field when setting values Defensively check that the field to be worked on is not NULL. Signed-off-by: Kees Cook Cc: stable@kernel.org Signed-off-by: Jiri Kosina --- diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index eadcc85e5a62..5b3e4cf7ca6b 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -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);