Skip to content

Commit 4ceabaf

Browse files
jwrdegoedebentiss
authored andcommitted
HID: core: Do not call request_module() in async context
request_module() may not be called form async context and in some cases hid devices may be added from an async context. One example of this happening is under hyperv, where this was triggering a WARN_ON in request_module(): [ 11.174497] hid_add_device+0xee/0x2b0 [hid] [ 11.174499] mousevsc_probe+0x223/0x2eb [hid_hyperv] [ 11.174501] vmbus_probe+0x3a/0x90 [ 11.174504] really_probe+0x229/0x420 [ 11.174506] driver_probe_device+0x115/0x130 [ 11.174507] __driver_attach_async_helper+0x87/0x90 [ 11.174509] async_run_entry_fn+0x37/0x150 This commit skips the request_module(), falling back to the old behavior of letting userspace deal with this, in case we are called from an async context. Cc: Lili Deng <[email protected]> Reported-by: Lili Deng <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent a025a18 commit 4ceabaf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/hid/hid-core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/vmalloc.h>
3131
#include <linux/sched.h>
3232
#include <linux/semaphore.h>
33+
#include <linux/async.h>
3334

3435
#include <linux/hid.h>
3536
#include <linux/hiddev.h>
@@ -2366,8 +2367,9 @@ int hid_add_device(struct hid_device *hdev)
23662367
* not first have hid-generic binding only to have it replaced
23672368
* immediately afterwards with a specialized driver.
23682369
*/
2369-
request_module("hid:b%04Xg%04Xv%08Xp%08X",
2370-
hdev->bus, hdev->group, hdev->vendor, hdev->product);
2370+
if (!current_is_async())
2371+
request_module("hid:b%04Xg%04Xv%08Xp%08X", hdev->bus,
2372+
hdev->group, hdev->vendor, hdev->product);
23712373

23722374
hid_debug_register(hdev, dev_name(&hdev->dev));
23732375
ret = device_add(&hdev->dev);

0 commit comments

Comments
 (0)