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.)

- Dave



--- 1.16/drivers/usb/hcd.c      Tue Apr  1 19:48:15 2003
+++ edited/drivers/usb/hcd.c    Wed Apr  2 16:49:15 2003
@@ -1033,8 +1033,10 @@
                        usb_pipeout (pipe)))
                return -EPIPE;
 
-       /* NOTE: 2.5 passes this value explicitly in submit() */
-       mem_flags = in_interrupt () ? GFP_ATOMIC : GFP_KERNEL;
+       /* NOTE: 2.5 passes this value explicitly in submit(),
+        * we must pessimize this on 2.4 to prevent deadlocks.
+        */
+       mem_flags = GFP_ATOMIC;
 
        /* FIXME there should be a sharable lock protecting us against
         * config/altsetting changes and disconnects, kicking in here.
--- 1.36/drivers/usb/usb.c      Wed Mar 26 17:21:59 2003
+++ edited/drivers/usb/usb.c    Wed Apr  2 16:48:44 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;

Reply via email to