Commit 2ae23854 authored by Mattias Nissler's avatar Mattias Nissler Committed by John W. Linville

rt2x00: Don't use unitialized rxdesc->size

rxdesc->size is unitialized before the desriptor has been read.
Move the truncation of the sk buffer to the moment all variables
have been initialized.
Signed-off-by: default avatarMattias Nissler <mattias.nissler@gmx.de>
Signed-off-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 2d1be5b0
...@@ -1123,13 +1123,10 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry, ...@@ -1123,13 +1123,10 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry,
/* /*
* Copy descriptor to the available headroom inside the skbuffer. * Copy descriptor to the available headroom inside the skbuffer.
* Remove the original copy by trimming the skbuffer.
*/ */
skb_push(entry->skb, offset); skb_push(entry->skb, offset);
memcpy(entry->skb->data, rxd, entry->queue->desc_size); memcpy(entry->skb->data, rxd, entry->queue->desc_size);
rxd = (__le32 *)entry->skb->data; rxd = (__le32 *)entry->skb->data;
skb_pull(entry->skb, offset);
skb_trim(entry->skb, rxdesc->size);
/* /*
* The descriptor is now aligned to 4 bytes and thus it is * The descriptor is now aligned to 4 bytes and thus it is
...@@ -1154,12 +1151,18 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry, ...@@ -1154,12 +1151,18 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry,
rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
rxdesc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS); rxdesc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS);
/*
* Adjust the skb memory window to the frame boundaries.
*/
skb_pull(entry->skb, offset);
skb_trim(entry->skb, rxdesc->size);
/* /*
* Set descriptor and data pointer. * Set descriptor and data pointer.
*/ */
skbdesc->data = entry->skb->data; skbdesc->data = entry->skb->data;
skbdesc->data_len = rxdesc->size; skbdesc->data_len = rxdesc->size;
skbdesc->desc = entry->skb->data - offset; skbdesc->desc = rxd;
skbdesc->desc_len = entry->queue->desc_size; skbdesc->desc_len = entry->queue->desc_size;
} }
......
...@@ -1376,13 +1376,10 @@ static void rt73usb_fill_rxdone(struct queue_entry *entry, ...@@ -1376,13 +1376,10 @@ static void rt73usb_fill_rxdone(struct queue_entry *entry,
/* /*
* Copy descriptor to the available headroom inside the skbuffer. * Copy descriptor to the available headroom inside the skbuffer.
* Remove the original copy by pulling the skbuffer.
*/ */
skb_push(entry->skb, offset); skb_push(entry->skb, offset);
memcpy(entry->skb->data, rxd, entry->queue->desc_size); memcpy(entry->skb->data, rxd, entry->queue->desc_size);
rxd = (__le32 *)entry->skb->data; rxd = (__le32 *)entry->skb->data;
skb_pull(entry->skb, offset + entry->queue->desc_size);
skb_trim(entry->skb, rxdesc->size);
/* /*
* The descriptor is now aligned to 4 bytes and thus it is * The descriptor is now aligned to 4 bytes and thus it is
...@@ -1404,12 +1401,18 @@ static void rt73usb_fill_rxdone(struct queue_entry *entry, ...@@ -1404,12 +1401,18 @@ static void rt73usb_fill_rxdone(struct queue_entry *entry,
rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
rxdesc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS); rxdesc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS);
/*
* Adjust the skb memory window to the frame boundaries.
*/
skb_pull(entry->skb, offset + entry->queue->desc_size);
skb_trim(entry->skb, rxdesc->size);
/* /*
* Set descriptor and data pointer. * Set descriptor and data pointer.
*/ */
skbdesc->data = entry->skb->data; skbdesc->data = entry->skb->data;
skbdesc->data_len = rxdesc->size; skbdesc->data_len = rxdesc->size;
skbdesc->desc = entry->skb->data - offset; skbdesc->desc = rxd;
skbdesc->desc_len = entry->queue->desc_size; skbdesc->desc_len = entry->queue->desc_size;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment