Re: [PATCH] HID: core: Do not call request_module() in async context

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 4, 2019 at 3:51 PM Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
>
> 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 <v-lide@xxxxxxxxxxxxx>
> Reported-by: Lili Deng <v-lide@xxxxxxxxxxxxx>
> Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>

Applied to for-5.2/core

Thanks!

Cheers,
Benjamin

> ---
>  drivers/hid/hid-core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index 7a4718995a39..77f89d2f8fa3 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -30,6 +30,7 @@
>  #include <linux/vmalloc.h>
>  #include <linux/sched.h>
>  #include <linux/semaphore.h>
> +#include <linux/async.h>
>
>  #include <linux/hid.h>
>  #include <linux/hiddev.h>
> @@ -2356,8 +2357,9 @@ int hid_add_device(struct hid_device *hdev)
>          * not first have hid-generic binding only to have it replaced
>          * immediately afterwards with a specialized driver.
>          */
> -       request_module("hid:b%04Xg%04Xv%08Xp%08X",
> -                      hdev->bus, hdev->group, hdev->vendor, hdev->product);
> +       if (!current_is_async())
> +               request_module("hid:b%04Xg%04Xv%08Xp%08X", hdev->bus,
> +                              hdev->group, hdev->vendor, hdev->product);
>
>         hid_debug_register(hdev, dev_name(&hdev->dev));
>         ret = device_add(&hdev->dev);
> --
> 2.21.0
>



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux