Skip to content

Commit

Permalink
HID: hidraw: fix improper mutex release
Browse files Browse the repository at this point in the history
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 <younghua.zheng@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Yonghua Zheng authored and Jiri Kosina committed Jul 31, 2013
1 parent 6f49801 commit 8e552e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/hid/hidraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -528,6 +527,7 @@ int hidraw_connect(struct hid_device *hid)
dev->exist = 1;
hid->hidraw = dev;

mutex_unlock(&minors_lock);
out:
return result;

Expand Down

0 comments on commit 8e552e5

Please sign in to comment.