Skip to content

Commit

Permalink
HID: fix tty<->hid deadlock
Browse files Browse the repository at this point in the history
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: Jiri Slaby <jirislaby@gmail.com>
Tested-by: <Valdis.Kletnieks@vt.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Jiri Slaby authored and Jiri Kosina committed Oct 14, 2008
1 parent d1d3a5f commit d92870d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,7 @@ static void hid_compat_load(struct work_struct *ws)
request_module("hid-dummy");
}
static DECLARE_WORK(hid_compat_work, hid_compat_load);
static struct workqueue_struct *hid_compat_wq;
#endif

static int __init hid_init(void)
Expand All @@ -1674,7 +1675,12 @@ static int __init hid_init(void)
goto err_bus;

#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

return 0;
Expand All @@ -1686,6 +1692,9 @@ static int __init hid_init(void)

static void __exit hid_exit(void)
{
#ifdef CONFIG_HID_COMPAT
destroy_workqueue(hid_compat_wq);
#endif
hidraw_exit();
bus_unregister(&hid_bus_type);
}
Expand Down

0 comments on commit d92870d

Please sign in to comment.