]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
usb: cdc-wdm: Fix a sleep-in-atomic-context bug in service_outstanding_interrupt()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Sat, 1 Sep 2018 08:12:10 +0000 (16:12 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Sep 2018 06:33:58 +0000 (08:33 +0200)
commit 6e22e3af7bb3a7b9dc53cb4687659f6e63fca427 upstream.

wdm_in_callback() is a completion handler function for the USB driver.
So it should not sleep. But it calls service_outstanding_interrupt(),
which calls usb_submit_urb() with GFP_KERNEL.

To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC.

This bug is found by my static analysis tool DSAC.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/class/cdc-wdm.c

index df0878c4810c8134b25b82405fe767b728d9601d..8e073c9739e9cec3f7cc67b8ddb42e629f8d0a30 100644 (file)
@@ -452,7 +452,7 @@ static int clear_wdm_read_flag(struct wdm_device *desc)
 
        set_bit(WDM_RESPONDING, &desc->flags);
        spin_unlock_irq(&desc->iuspin);
-       rv = usb_submit_urb(desc->response, GFP_KERNEL);
+       rv = usb_submit_urb(desc->response, GFP_ATOMIC);
        spin_lock_irq(&desc->iuspin);
        if (rv) {
                dev_err(&desc->intf->dev,