diff options
| -rw-r--r-- | drivers/hid/hidraw.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 9c2d7c23f296..b9a76e3a7f17 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | #include <linux/hid.h> | 34 | #include <linux/hid.h> |
| 35 | #include <linux/mutex.h> | 35 | #include <linux/mutex.h> |
| 36 | #include <linux/sched.h> | 36 | #include <linux/sched.h> |
| 37 | #include <linux/string.h> | ||
| 37 | 38 | ||
| 38 | #include <linux/hidraw.h> | 39 | #include <linux/hidraw.h> |
| 39 | 40 | ||
| @@ -123,7 +124,6 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, | |||
| 123 | 124 | ||
| 124 | dev = hidraw_table[minor]->hid; | 125 | dev = hidraw_table[minor]->hid; |
| 125 | 126 | ||
| 126 | |||
| 127 | if (count > HID_MAX_BUFFER_SIZE) { | 127 | if (count > HID_MAX_BUFFER_SIZE) { |
| 128 | hid_warn(dev, "pid %d passed too large report\n", | 128 | hid_warn(dev, "pid %d passed too large report\n", |
| 129 | task_pid_nr(current)); | 129 | task_pid_nr(current)); |
| @@ -138,17 +138,12 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, | |||
| 138 | goto out; | 138 | goto out; |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | buf = kmalloc(count * sizeof(__u8), GFP_KERNEL); | 141 | buf = memdup_user(buffer, count); |
| 142 | if (!buf) { | 142 | if (IS_ERR(buf)) { |
| 143 | ret = -ENOMEM; | 143 | ret = PTR_ERR(buf); |
| 144 | goto out; | 144 | goto out; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | if (copy_from_user(buf, buffer, count)) { | ||
| 148 | ret = -EFAULT; | ||
| 149 | goto out_free; | ||
| 150 | } | ||
| 151 | |||
| 152 | if ((report_type == HID_OUTPUT_REPORT) && | 147 | if ((report_type == HID_OUTPUT_REPORT) && |
| 153 | !(dev->quirks & HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP)) { | 148 | !(dev->quirks & HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP)) { |
| 154 | ret = hid_hw_output_report(dev, buf, count); | 149 | ret = hid_hw_output_report(dev, buf, count); |
