Skip to contentSkip to conversation

gadgetfs: ep_io - wait until IRQ finishes

PATCH In review Jozef Martiniak 3 participants 4 messages Jul 8, 2022 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gadgetfs: ep_io - wait until IRQ finishes

after usb_ep_queue() if wait_for_completion_interruptible() is interrupted we need to wait until IRQ gets finished.

Otherwise complete() from epio_complete() can corrupt stack.

---
 drivers/usb/gadget/legacy/inode.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/gadget/legacy/inode.c +1 -0
index 79990597c39f..01c3ead7d1b4 100644
@@ -362,6 +362,7 @@ ep_io (struct ep_data *epdata, void *buf, unsigned len)
 				spin_unlock_irq (&epdata->dev->lock);
 
 				DBG (epdata->dev, "endpoint gone\n");
+				wait_for_completion(&done);
 				epdata->status = -ENODEV;
 			}
 		}
Signature · 1 line
2.25.1
#1 lore raw
Quoted 6 lines · Jozef Martiniak

after usb_ep_queue() if wait_for_completion_interruptible() is interrupted we need to wait until IRQ gets finished.

Otherwise complete() from epio_complete() can corrupt stack.

What commit id does this fix?

thanks,

greg k-h

author
#2 lore raw

The first commit 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2

pi 8. 7. 2022 o 9:19 Greg Kroah-Hartman <[email protected]> napísal(a):

Quoted 14 lines · Jozef Martiniak
Quoted 6 lines

after usb_ep_queue() if wait_for_completion_interruptible() is interrupted we need to wait until IRQ gets finished.

Otherwise complete() from epio_complete() can corrupt stack.

What commit id does this fix?

thanks,

greg k-h

Acked-by on v1 1/1
#3 lore raw
In reply to Jozef Martiniak
Quoted 2 lines · Jozef Martiniak

after usb_ep_queue() if wait_for_completion_interruptible() is interrupted we need to wait until IRQ gets finished.

This should say "request" or "I/O request", not "IRQ". Not a big deal.

Quoted 5 lines

Otherwise complete() from epio_complete() can corrupt stack.

---

Quoted 18 lines
 drivers/usb/gadget/legacy/inode.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/gadget/legacy/inode.c +1 -0
index 79990597c39f..01c3ead7d1b4 100644
@@ -362,6 +362,7 @@ ep_io (struct ep_data *epdata, void *buf, unsigned len)
 				spin_unlock_irq (&epdata->dev->lock);
 
 				DBG (epdata->dev, "endpoint gone\n");
+				wait_for_completion(&done);
 				epdata->status = -ENODEV;
 			}
 		}
Signature · 1 line
2.25.1