提交 40561b84 编写于 作者: I Ivo van Doorn 提交者: David S. Miller

rt2x00: Data and desc pointer initialization

rt2500usb and rt73usb data and desc pointer initialization
was incorrect because it was using uninitialized variables
to determine the length.

In addition rt2500usb used skb_pull and removed the ieee80211
from each received frame instead of using skb_trim to remove
the device descriptor from the frame.

Finally this also fixes the descriptor override when 4 byte
aligning occured. We still need a completely valid descriptor
when using the TX/RX dumping capabilities in debugfs.
Signed-off-by: NIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 dd0d43ea
...@@ -1139,16 +1139,13 @@ static void rt2500usb_fill_rxdone(struct data_entry *entry, ...@@ -1139,16 +1139,13 @@ static void rt2500usb_fill_rxdone(struct data_entry *entry,
desc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); desc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
desc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS); desc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS);
/*
* Trim the skb to clear the descriptor area.
*/
skb_pull(entry->skb, entry->ring->desc_size);
/* /*
* Set descriptor and data pointer. * Set descriptor and data pointer.
*/ */
skbdesc->desc = entry->skb->data + skbdesc->data_len; skbdesc->desc = entry->skb->data + desc->size;
skbdesc->desc_len = entry->ring->desc_size;
skbdesc->data = entry->skb->data; skbdesc->data = entry->skb->data;
skbdesc->data_len = desc->size;
} }
/* /*
......
...@@ -257,6 +257,13 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb) ...@@ -257,6 +257,13 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
if (urb->actual_length < entry->ring->desc_size || urb->status) if (urb->actual_length < entry->ring->desc_size || urb->status)
goto skip_entry; goto skip_entry;
/*
* Fill in skb descriptor
*/
skbdesc = get_skb_desc(entry->skb);
skbdesc->ring = ring;
skbdesc->entry = entry;
memset(&desc, 0, sizeof(desc)); memset(&desc, 0, sizeof(desc));
rt2x00dev->ops->lib->fill_rxdone(entry, &desc); rt2x00dev->ops->lib->fill_rxdone(entry, &desc);
...@@ -283,9 +290,6 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb) ...@@ -283,9 +290,6 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
/* /*
* The data behind the ieee80211 header must be * The data behind the ieee80211 header must be
* aligned on a 4 byte boundary. * aligned on a 4 byte boundary.
* After that trim the entire buffer down to only
* contain the valid frame data excluding the device
* descriptor.
*/ */
hdr = (struct ieee80211_hdr *)entry->skb->data; hdr = (struct ieee80211_hdr *)entry->skb->data;
header_size = header_size =
...@@ -295,16 +299,17 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb) ...@@ -295,16 +299,17 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
skb_push(entry->skb, 2); skb_push(entry->skb, 2);
memmove(entry->skb->data, entry->skb->data + 2, skb->len - 2); memmove(entry->skb->data, entry->skb->data + 2, skb->len - 2);
} }
skb_trim(entry->skb, desc.size);
/* /*
* Fill in skb descriptor * Trim the entire buffer down to only contain the valid frame data
* excluding the device descriptor. The position of the descriptor
* varies. This means that we should check where the descriptor is
* and decide if we need to pull the data pointer to exclude the
* device descriptor.
*/ */
skbdesc = get_skb_desc(entry->skb); if (skbdesc->data > skbdesc->desc)
skbdesc->desc_len = entry->ring->desc_size; skb_pull(entry->skb, skbdesc->desc_len);
skbdesc->data_len = entry->skb->len; skb_trim(entry->skb, desc.size);
skbdesc->ring = ring;
skbdesc->entry = entry;
/* /*
* Send the frame to rt2x00lib for further processing. * Send the frame to rt2x00lib for further processing.
......
...@@ -1397,16 +1397,13 @@ static void rt73usb_fill_rxdone(struct data_entry *entry, ...@@ -1397,16 +1397,13 @@ static void rt73usb_fill_rxdone(struct data_entry *entry,
desc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); desc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
desc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS); desc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS);
/*
* Pull the skb to clear the descriptor area.
*/
skb_pull(entry->skb, entry->ring->desc_size);
/* /*
* Set descriptor and data pointer. * Set descriptor and data pointer.
*/ */
skbdesc->desc = entry->skb->data - skbdesc->desc_len; skbdesc->desc = entry->skb->data;
skbdesc->data = entry->skb->data; skbdesc->desc_len = entry->ring->desc_size;
skbdesc->data = entry->skb->data + entry->ring->desc_size;
skbdesc->data_len = desc->size;
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册