ChangeSet 1.1101.3.8, 2003/04/09 17:02:25-07:00, david-b@pacbell.net

[PATCH] USB: usbcore deadlock paranoia

Related to a comment from Pete Zaitcev:

> ... Make sure ...  that you
> do not have any of this crap:
>  p = kmalloc(N, in_interrupt()? GFP_ATOMIC: GFP_NOIO);
> -- it's a sure way to deadlock

This patch fixes up two similar places.  The fix is actually
pessimizing behavior.  In 2.5 the API passes the GFP_* flags
down, so this can just be a reason to upgrade ASAP ... ;)

(Prevents sleeping when these routines are called by a task
that's holding a spinlock, which can be trouble.)


 drivers/usb/usb.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


diff -Nru a/drivers/usb/usb.c b/drivers/usb/usb.c
--- a/drivers/usb/usb.c	Fri Apr 18 15:00:53 2003
+++ b/drivers/usb/usb.c	Fri Apr 18 15:00:53 2003
@@ -1005,7 +1005,7 @@
 	struct urb *urb;
 
 	urb = (struct urb *)kmalloc(sizeof(struct urb) + iso_packets * sizeof(struct iso_packet_descriptor),
-	      in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
+			/* pessimize to prevent deadlocks */ GFP_ATOMIC);
 	if (!urb) {
 		err("alloc_urb: kmalloc failed");
 		return NULL;
