HID: hidraw: Add spinlock in struct hidraw to protect list
authorYonghua Zheng <younghua.zheng@gmail.com>
Mon, 26 Aug 2013 15:38:35 +0000 (23:38 +0800)
committerlyz <lyz@rock-chips.com>
Fri, 14 Mar 2014 10:21:18 +0000 (18:21 +0800)
commit31ce81ee05fc09766d8c21c523f64a873464a0ef
tree15fc7251a1c807ea526af9e5620ced5ca5c5f092
parent41d7b1d4eb1987074a5758d5d6da91b3e926259c
HID: hidraw: Add spinlock in struct hidraw to protect list

It is unsafe to call list_for_each_entry in hidraw_report_event to
traverse each hidraw_list node without a lock protection, the list
could be modified if someone calls hidraw_release and list_del to
remove itself from the list, this can cause hidraw_report_event
to touch a deleted list struct and panic.

To prevent this, introduce a spinlock in struct hidraw to protect
list from concurrent access.

Signed-off-by: Yonghua Zheng <younghua.zheng@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hidraw.c
include/linux/hidraw.h