Thread (4 messages) 4 messages, 2 authors, 2013-09-04

Re: [PATCH 14/14] HID: check for NULL field when setting values

From: Jiri Kosina <hidden>
Date: 2013-09-04 10:05:39

On Wed, 28 Aug 2013, Jiri Kosina wrote:
From: Kees Cook <redacted>

Defensively check that the field to be worked on is not NULL.
Applied.
quoted hunk ↗ jump to hunk
Signed-off-by: Kees Cook <redacted>
Cc: stable@kernel.org
---
 drivers/hid/hid-core.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 55798b2..192be6b 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1206,7 +1206,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);
 
-- 
Jiri Kosina
SUSE Labs
-- 
Jiri Kosina
SUSE Labs
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help