Skip to contentSkip to conversation

usb: cdc-wdm: Fix a sleep-in-atomic-context bug in service_outstanding_interrupt()

PATCH Superseded Jia-Ju Bai 1 participant 1 message Sep 1, 2018 USB

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

PATCH 1/1 usb: cdc-wdm: Fix a sleep-in-atomic-context bug in service_outstanding_interrupt()

wdm_in_callback() is a completion handler function for the USB driver. So it should not sleep.

To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC.

This bug is found by my static analysis tool DSAC.

---
 drivers/usb/class/cdc-wdm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/class/cdc-wdm.c +1 -1
index a0d284ef3f40..632a2bfabc08 100644
@@ -458,7 +458,7 @@ static int service_outstanding_interrupt(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,