提交 dfd395af 编写于 作者: D Dan Carpenter 提交者: Jiri Kosina

HID: unlock properly on error paths in hidraw_ioctl()

We can't return immediately because lock_kernel() is held.
Signed-off-by: NDan Carpenter <error27@gmail.com>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 35cfd1d9
无相关合并请求
...@@ -267,8 +267,10 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, ...@@ -267,8 +267,10 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
default: default:
{ {
struct hid_device *hid = dev->hid; struct hid_device *hid = dev->hid;
if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ) if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ) {
return -EINVAL; ret = -EINVAL;
break;
}
if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWNAME(0))) { if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWNAME(0))) {
int len; int len;
...@@ -277,8 +279,9 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, ...@@ -277,8 +279,9 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
len = strlen(hid->name) + 1; len = strlen(hid->name) + 1;
if (len > _IOC_SIZE(cmd)) if (len > _IOC_SIZE(cmd))
len = _IOC_SIZE(cmd); len = _IOC_SIZE(cmd);
return copy_to_user(user_arg, hid->name, len) ? ret = copy_to_user(user_arg, hid->name, len) ?
-EFAULT : len; -EFAULT : len;
break;
} }
if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWPHYS(0))) { if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWPHYS(0))) {
...@@ -288,8 +291,9 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, ...@@ -288,8 +291,9 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
len = strlen(hid->phys) + 1; len = strlen(hid->phys) + 1;
if (len > _IOC_SIZE(cmd)) if (len > _IOC_SIZE(cmd))
len = _IOC_SIZE(cmd); len = _IOC_SIZE(cmd);
return copy_to_user(user_arg, hid->phys, len) ? ret = copy_to_user(user_arg, hid->phys, len) ?
-EFAULT : len; -EFAULT : len;
break;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部