]> Pileus Git - ~andy/linux/blobdiff - drivers/net/wireless/rt2x00/rt73usb.c
rt2x00: Preserve descriptor information after memmove()
[~andy/linux] / drivers / net / wireless / rt2x00 / rt73usb.c
index 2191d8b94a894b4575ae47814ee84a01fbde039b..1bcf8c132cdc357ab5f3e97e520bace24ac4b172 100644 (file)
@@ -1403,20 +1403,22 @@ static void rt73usb_fill_rxdone(struct queue_entry *entry,
 {
        struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
        __le32 *rxd = (__le32 *)entry->skb->data;
-       unsigned int offset = entry->queue->desc_size + 2;
        u32 word0;
        u32 word1;
 
        /*
-        * Copy descriptor to the available headroom inside the skbuffer.
+        * Copy descriptor to the skb->cb array, this has 2 benefits:
+        * 1) Each descriptor word is 4 byte aligned.
+        * 2) Descriptor is safe  from moving of frame data in rt2x00usb.
         */
-       skb_push(entry->skb, offset);
-       memcpy(entry->skb->data, rxd, entry->queue->desc_size);
-       rxd = (__le32 *)entry->skb->data;
+       skbdesc->desc_len =
+           min_t(u16, entry->queue->desc_size, sizeof(entry->skb->cb));
+       memcpy(entry->skb->cb, rxd, skbdesc->desc_len);
+       skbdesc->desc = entry->skb->cb;
+       rxd = (__le32 *)skbdesc->desc;
 
        /*
-        * The descriptor is now aligned to 4 bytes and thus it is
-        * now safe to read it on all architectures.
+        * It is now safe to read the descriptor on all architectures.
         */
        rt2x00_desc_read(rxd, 0, &word0);
        rt2x00_desc_read(rxd, 1, &word1);
@@ -1442,18 +1444,12 @@ static void rt73usb_fill_rxdone(struct queue_entry *entry,
                rxdesc->dev_flags |= RXDONE_MY_BSS;
 
        /*
-        * Adjust the skb memory window to the frame boundaries.
+        * Set skb pointers, and update frame information.
         */
-       skb_pull(entry->skb, offset + entry->queue->desc_size);
+       skb_pull(entry->skb, entry->queue->desc_size);
        skb_trim(entry->skb, rxdesc->size);
-
-       /*
-        * Set descriptor and data pointer.
-        */
        skbdesc->data = entry->skb->data;
        skbdesc->data_len = rxdesc->size;
-       skbdesc->desc = rxd;
-       skbdesc->desc_len = entry->queue->desc_size;
 }
 
 /*