staging: vt6656: Include re_alloc_skb within lock.
authorMalcolm Priestley <tvboxspy@gmail.com>
Sat, 5 Jul 2014 18:24:26 +0000 (19:24 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Jul 2014 23:03:57 +0000 (16:03 -0700)
Remove variable re_alloc_skb and merge code within urb->actual_length.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vt6656/usbpipe.c

index c5d4047befe0a88db1b982a96f2d0ca205bf1e33..a7af4f58898e233a993fd89c2de0e5dcc1893a46 100644 (file)
@@ -276,7 +276,6 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
        struct vnt_rcb *rcb = urb->context;
        struct vnt_private *priv = rcb->pDevice;
        unsigned long flags;
-       int re_alloc_skb = false;
 
        switch (urb->status) {
        case 0:
@@ -294,24 +293,22 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
        if (urb->actual_length) {
                spin_lock_irqsave(&priv->lock, flags);
 
-               if (vnt_rx_data(priv, rcb, urb->actual_length))
-                       re_alloc_skb = true;
+               if (vnt_rx_data(priv, rcb, urb->actual_length)) {
+                       rcb->skb = dev_alloc_skb(priv->rx_buf_sz);
+                       if (!rcb->skb) {
+                               dev_dbg(&priv->usb->dev,
+                                       "Failed to re-alloc rx skb\n");
 
-               spin_unlock_irqrestore(&priv->lock, flags);
-       }
-
-       if (re_alloc_skb) {
-               rcb->skb = dev_alloc_skb(priv->rx_buf_sz);
-               if (!rcb->skb) {
-                       dev_dbg(&priv->usb->dev, "Failed to re-alloc rx skb\n");
-
-                       rcb->bBoolInUse = false;
-
-                       return;
+                               rcb->bBoolInUse = false;
+                               spin_unlock_irqrestore(&priv->lock, flags);
+                               return;
+                       }
                }
 
                urb->transfer_buffer = skb_put(rcb->skb,
                                                skb_tailroom(rcb->skb));
+
+               spin_unlock_irqrestore(&priv->lock, flags);
        }
 
        if (usb_submit_urb(urb, GFP_ATOMIC)) {