]> Git Repo - linux.git/commitdiff
HID: hidraw: fix improper mutex release
authorYonghua Zheng <[email protected]>
Tue, 30 Jul 2013 06:16:10 +0000 (14:16 +0800)
committerJiri Kosina <[email protected]>
Wed, 31 Jul 2013 17:48:55 +0000 (19:48 +0200)
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: Yonghua Zheng <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
drivers/hid/hidraw.c

index a7451632ceb46bad87845c444fc1897973e94ef9..6f1feb2c2e97b5defb0628d92bfc98a719449685 100644 (file)
@@ -518,7 +518,6 @@ int hidraw_connect(struct hid_device *hid)
                goto out;
        }
 
-       mutex_unlock(&minors_lock);
        init_waitqueue_head(&dev->wait);
        INIT_LIST_HEAD(&dev->list);
 
@@ -528,6 +527,7 @@ int hidraw_connect(struct hid_device *hid)
        dev->exist = 1;
        hid->hidraw = dev;
 
+       mutex_unlock(&minors_lock);
 out:
        return result;
 
This page took 0.060428 seconds and 4 git commands to generate.