Commit 8e552e53 authored by Yonghua Zheng's avatar Yonghua Zheng Committed by Jiri Kosina

HID: hidraw: fix improper mutex release

Mutex can not be released unless all hid_device members are properly
initialized. Otherwise it would result in a race condition that can
cause NULL pointer kernel panic issue in hidraw_open where it uses
uninitialized 'list' member in list_add_tail().
Signed-off-by: default avatarYonghua Zheng <younghua.zheng@gmail.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 6f498018
...@@ -518,7 +518,6 @@ int hidraw_connect(struct hid_device *hid) ...@@ -518,7 +518,6 @@ int hidraw_connect(struct hid_device *hid)
goto out; goto out;
} }
mutex_unlock(&minors_lock);
init_waitqueue_head(&dev->wait); init_waitqueue_head(&dev->wait);
INIT_LIST_HEAD(&dev->list); INIT_LIST_HEAD(&dev->list);
...@@ -528,6 +527,7 @@ int hidraw_connect(struct hid_device *hid) ...@@ -528,6 +527,7 @@ int hidraw_connect(struct hid_device *hid)
dev->exist = 1; dev->exist = 1;
hid->hidraw = dev; hid->hidraw = dev;
mutex_unlock(&minors_lock);
out: out:
return result; return result;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment