Yoshihiro:

While going through the HCDs, I found this bug and some simplifications
in your driver.  While you hold a spinlock, memory allocation cannot
use anything other than GFP_ATOMIC.

Do you agree that the patch below is correct?  If yes, then I will fold 
it in with the new urb->status updates.

Alan Stern



Index: usb-2.6/drivers/usb/host/r8a66597-hcd.c
===================================================================
--- usb-2.6.orig/drivers/usb/host/r8a66597-hcd.c
+++ usb-2.6/drivers/usb/host/r8a66597-hcd.c
@@ -1197,7 +1197,7 @@ static void packet_read(struct r8a66597 
                td->short_packet = 1;
                if (urb->transfer_buffer_length != urb->actual_length &&
                    urb->transfer_flags & URB_SHORT_NOT_OK)
-                       td->urb->status = -EREMOTEIO;
+                       urb->status = -EREMOTEIO;
        }
        if (usb_pipeisoc(urb->pipe)) {
                urb->iso_frame_desc[td->iso_cnt].actual_length = size;
@@ -1222,8 +1222,8 @@ static void packet_read(struct r8a66597 
        }
 
        if (finish && pipenum != 0) {
-               if (td->urb->status == -EINPROGRESS)
-                       td->urb->status = 0;
+               if (urb->status == -EINPROGRESS)
+                       urb->status = 0;
                finish_request(r8a66597, td, pipenum, urb);
        }
 }
@@ -1247,7 +1247,7 @@ static void packet_write(struct r8a66597
                pipe_stop(r8a66597, td->pipe);
                pipe_irq_disable(r8a66597, pipenum);
                err("out write fifo not ready. (%d)", pipenum);
-               finish_request(r8a66597, td, pipenum, td->urb);
+               finish_request(r8a66597, td, pipenum, urb);
                return;
        }
 
@@ -1693,13 +1693,12 @@ static void set_address_zero(struct r8a6
 
 static struct r8a66597_td *r8a66597_make_td(struct r8a66597 *r8a66597,
                                            struct urb *urb,
-                                           struct usb_host_endpoint *hep,
-                                           gfp_t mem_flags)
+                                           struct usb_host_endpoint *hep)
 {
        struct r8a66597_td *td;
        u16 pipenum;
 
-       td = kzalloc(sizeof(struct r8a66597_td), mem_flags);
+       td = kzalloc(sizeof(struct r8a66597_td), GFP_ATOMIC);
        if (td == NULL)
                return NULL;
 
@@ -1738,7 +1737,8 @@ static int r8a66597_urb_enqueue(struct u
        }
 
        if (!hep->hcpriv) {
-               hep->hcpriv = kzalloc(sizeof(struct r8a66597_pipe), mem_flags);
+               hep->hcpriv = kzalloc(sizeof(struct r8a66597_pipe),
+                               GFP_ATOMIC);
                if (!hep->hcpriv) {
                        ret = -ENOMEM;
                        goto error;
@@ -1752,7 +1752,7 @@ static int r8a66597_urb_enqueue(struct u
                init_pipe_config(r8a66597, urb);
 
        set_address_zero(r8a66597, urb);
-       td = r8a66597_make_td(r8a66597, urb, hep, mem_flags);
+       td = r8a66597_make_td(r8a66597, urb, hep);
        if (td == NULL) {
                ret = -ENOMEM;
                goto error;


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to