summaryrefslogtreecommitdiff
path: root/include/linux/hid.h
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2014-02-10 12:58:59 -0500
committerJiri Kosina <jkosina@suse.cz>2014-02-17 14:58:59 +0100
commit5318251744b2c8a288f91f4e53ed69f2a01d6412 (patch)
tree48fe1594feac12afa0832b271460ad58b0596afc /include/linux/hid.h
parent7e0bc880fce51ba3bd9128b8df9dc59567c5f73a (diff)
HID: core: check parameters when sending/receiving data from the device
It is better to check them soon enough before triggering any kernel panic. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'include/linux/hid.h')
-rw-r--r--include/linux/hid.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 09fbbd7fb784..60f3ff762376 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -989,6 +989,9 @@ static inline int hid_hw_raw_request(struct hid_device *hdev,
unsigned char reportnum, __u8 *buf,
size_t len, unsigned char rtype, int reqtype)
{
+ if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf)
+ return -EINVAL;
+
if (hdev->ll_driver->raw_request)
return hdev->ll_driver->raw_request(hdev, reportnum, buf, len,
rtype, reqtype);
@@ -1008,6 +1011,9 @@ static inline int hid_hw_raw_request(struct hid_device *hdev,
static inline int hid_hw_output_report(struct hid_device *hdev, __u8 *buf,
size_t len)
{
+ if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf)
+ return -EINVAL;
+
if (hdev->ll_driver->output_report)
return hdev->ll_driver->output_report(hdev, buf, len);