提交 d92870dd 编写于 作者: J Jiri Slaby 提交者: Jiri Kosina

HID: fix tty<->hid deadlock

hid_compat_load() runs on the default workqueue, it request_module(), it
execs modprobe, it exits, tty flushes default workqueue, it hangs, because
we are still in it.
Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
Tested-by: <Valdis.Kletnieks@vt.edu>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 d1d3a5f6
...@@ -1657,6 +1657,7 @@ static void hid_compat_load(struct work_struct *ws) ...@@ -1657,6 +1657,7 @@ static void hid_compat_load(struct work_struct *ws)
request_module("hid-dummy"); request_module("hid-dummy");
} }
static DECLARE_WORK(hid_compat_work, hid_compat_load); static DECLARE_WORK(hid_compat_work, hid_compat_load);
static struct workqueue_struct *hid_compat_wq;
#endif #endif
static int __init hid_init(void) static int __init hid_init(void)
...@@ -1674,7 +1675,12 @@ static int __init hid_init(void) ...@@ -1674,7 +1675,12 @@ static int __init hid_init(void)
goto err_bus; goto err_bus;
#ifdef CONFIG_HID_COMPAT #ifdef CONFIG_HID_COMPAT
schedule_work(&hid_compat_work); hid_compat_wq = create_workqueue("hid_compat");
if (!hid_compat_wq) {
hidraw_exit();
goto err;
}
queue_work(hid_compat_wq, &hid_compat_work);
#endif #endif
return 0; return 0;
...@@ -1686,6 +1692,9 @@ static int __init hid_init(void) ...@@ -1686,6 +1692,9 @@ static int __init hid_init(void)
static void __exit hid_exit(void) static void __exit hid_exit(void)
{ {
#ifdef CONFIG_HID_COMPAT
destroy_workqueue(hid_compat_wq);
#endif
hidraw_exit(); hidraw_exit();
bus_unregister(&hid_bus_type); bus_unregister(&hid_bus_type);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册