aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hidraw.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hidraw.c')
-rw-r--r--drivers/hid/hidraw.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 54409cba018c..c79578b5a788 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -101,8 +101,8 @@ out:
101 return ret; 101 return ret;
102} 102}
103 103
104/* the first byte is expected to be a report number */ 104/* The first byte is expected to be a report number.
105/* This function is to be called with the minors_lock mutex held */ 105 * This function is to be called with the minors_lock mutex held */
106static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, size_t count, unsigned char report_type) 106static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, size_t count, unsigned char report_type)
107{ 107{
108 unsigned int minor = iminor(file->f_path.dentry->d_inode); 108 unsigned int minor = iminor(file->f_path.dentry->d_inode);
@@ -166,11 +166,11 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t
166 166
167 167
168/* This function performs a Get_Report transfer over the control endpoint 168/* This function performs a Get_Report transfer over the control endpoint
169 per section 7.2.1 of the HID specification, version 1.1. The first byte 169 * per section 7.2.1 of the HID specification, version 1.1. The first byte
170 of buffer is the report number to request, or 0x0 if the defice does not 170 * of buffer is the report number to request, or 0x0 if the defice does not
171 use numbered reports. The report_type parameter can be HID_FEATURE_REPORT 171 * use numbered reports. The report_type parameter can be HID_FEATURE_REPORT
172 or HID_INPUT_REPORT. This function is to be called with the minors_lock 172 * or HID_INPUT_REPORT. This function is to be called with the minors_lock
173 mutex held. */ 173 * mutex held. */
174static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t count, unsigned char report_type) 174static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t count, unsigned char report_type)
175{ 175{
176 unsigned int minor = iminor(file->f_path.dentry->d_inode); 176 unsigned int minor = iminor(file->f_path.dentry->d_inode);
@@ -207,7 +207,7 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
207 } 207 }
208 208
209 /* Read the first byte from the user. This is the report number, 209 /* Read the first byte from the user. This is the report number,
210 which is passed to dev->hid_get_raw_report(). */ 210 * which is passed to dev->hid_get_raw_report(). */
211 if (copy_from_user(&report_number, buffer, 1)) { 211 if (copy_from_user(&report_number, buffer, 1)) {
212 ret = -EFAULT; 212 ret = -EFAULT;
213 goto out_free; 213 goto out_free;
@@ -395,12 +395,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
395 } 395 }
396 396
397 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWNAME(0))) { 397 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWNAME(0))) {
398 int len; 398 int len = strlen(hid->name) + 1;
399 if (!hid->name) {
400 ret = 0;
401 break;
402 }
403 len = strlen(hid->name) + 1;
404 if (len > _IOC_SIZE(cmd)) 399 if (len > _IOC_SIZE(cmd))
405 len = _IOC_SIZE(cmd); 400 len = _IOC_SIZE(cmd);
406 ret = copy_to_user(user_arg, hid->name, len) ? 401 ret = copy_to_user(user_arg, hid->name, len) ?
@@ -409,12 +404,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
409 } 404 }
410 405
411 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWPHYS(0))) { 406 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWPHYS(0))) {
412 int len; 407 int len = strlen(hid->phys) + 1;
413 if (!hid->phys) {
414 ret = 0;
415 break;
416 }
417 len = strlen(hid->phys) + 1;
418 if (len > _IOC_SIZE(cmd)) 408 if (len > _IOC_SIZE(cmd))
419 len = _IOC_SIZE(cmd); 409 len = _IOC_SIZE(cmd);
420 ret = copy_to_user(user_arg, hid->phys, len) ? 410 ret = copy_to_user(user_arg, hid->phys, len) ?