Skip to contentSkip to conversation

rtlwifi: Allocate new skb before modifying old

PATCH In review Mike McCormack 2 participants 2 messages Jun 6, 2011 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 rtlwifi: Allocate new skb before modifying old

Make sure not to modify the skb we resubmit.

---
 drivers/net/wireless/rtlwifi/pci.c |   28 +++++++++++++---------------
 1 files changed, 13 insertions(+), 15 deletions(-)
drivers/net/wireless/rtlwifi/pci.c +13 -15
index fc44005..e502db0 100644
@@ -670,6 +670,19 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
 							 &rx_status,
 							 (u8 *) pdesc, skb);
 
+			new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
+			if (unlikely(!new_skb)) {
+				RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV),
+					 DBG_DMESG,
+					 ("can't alloc skb for rx\n"));
+				goto done;
+			}
+
+			pci_unmap_single(rtlpci->pdev,
+					 *((dma_addr_t *) skb->cb),
+					 rtlpci->rxbuffersize,
+					 PCI_DMA_FROMDEVICE);
+
 			skb_put(skb, rtlpriv->cfg->ops->get_desc((u8 *) pdesc,
 							 false,
 							 HW_DESC_RXPKT_LEN));
@@ -686,21 +699,6 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
 			hdr = rtl_get_hdr(skb);
 			fc = rtl_get_fc(skb);
 
-			/* try for new buffer - if allocation fails, drop
-			 * frame and reuse old buffer
-			 */
-			new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
-			if (unlikely(!new_skb)) {
-				RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV),
-					 DBG_DMESG,
-					 ("can't alloc skb for rx\n"));
-				goto done;
-			}
-			pci_unmap_single(rtlpci->pdev,
-					 *((dma_addr_t *) skb->cb),
-					 rtlpci->rxbuffersize,
-					 PCI_DMA_FROMDEVICE);
-
 			if (!stats.crc && !stats.hwerror) {
 				memcpy(IEEE80211_SKB_RXCB(skb), &rx_status,
 				       sizeof(rx_status));
Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 3 lines · Mike McCormack

Make sure not to modify the skb we resubmit.

I think this is a bug introduced by commit a9e1286975843042480. If it is, please resubmit as a single patch with subject "rtlwifi: Fix case where modified skb could be resubmitted", or something like this. Any bug fixes will go into 3.0, while the enhancements will go to 3.1.

Larry

Quoted 50 lines
---
  drivers/net/wireless/rtlwifi/pci.c |   28 +++++++++++++---------------
  1 files changed, 13 insertions(+), 15 deletions(-)
drivers/net/wireless/rtlwifi/pci.c +13 -15
index fc44005..e502db0 100644
@@ -670,6 +670,19 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
  							&rx_status,
  							 (u8 *) pdesc, skb);
 
+			new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
+			if (unlikely(!new_skb)) {
+				RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV),
+					 DBG_DMESG,
+					 ("can't alloc skb for rx\n"));
+				goto done;
+			}
+
+			pci_unmap_single(rtlpci->pdev,
+					 *((dma_addr_t *) skb->cb),
+					 rtlpci->rxbuffersize,
+					 PCI_DMA_FROMDEVICE);
+
  			skb_put(skb, rtlpriv->cfg->ops->get_desc((u8 *) pdesc,
  							 false,
  							 HW_DESC_RXPKT_LEN));
@@ -686,21 +699,6 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
  			hdr = rtl_get_hdr(skb);
  			fc = rtl_get_fc(skb);
 
-			/* try for new buffer - if allocation fails, drop
-			 * frame and reuse old buffer
-			 */
-			new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
-			if (unlikely(!new_skb)) {
-				RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV),
-					 DBG_DMESG,
-					 ("can't alloc skb for rx\n"));
-				goto done;
-			}
-			pci_unmap_single(rtlpci->pdev,
-					 *((dma_addr_t *) skb->cb),
-					 rtlpci->rxbuffersize,
-					 PCI_DMA_FROMDEVICE);
-
  			if (!stats.crc&&  !stats.hwerror) {
  				memcpy(IEEE80211_SKB_RXCB(skb),&rx_status,
  				       sizeof(rx_status));