netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtlwifi: get buffer_desc before trying to alloc new skb
@ 2015-03-12 11:33 Yang Bai
  2015-03-12 16:03 ` Larry Finger
       [not found] ` <1426160036-1542-1-git-send-email-hamo.by-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Yang Bai @ 2015-03-12 11:33 UTC (permalink / raw)
  To: Larry.Finger, chaoming_li, kvalo
  Cc: linux-wireless, netdev, linux-kernel, hamo.by

if rtlpriv->use_new_trx_flow == true and we run out of memory
to alloc a new skb, we will directly jump to no_new tag with
buffer_desc == NULL. Then we will dereference this NULL pointer
in function _rtl_pci_init_one_rxdesc.

Signed-off-by: Yang Bai <hamo.by@gmail.com>
---
 drivers/net/wireless/rtlwifi/pci.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index a62170e..7fe04d1 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -820,17 +820,19 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
 		pci_unmap_single(rtlpci->pdev, *((dma_addr_t *)skb->cb),
 				 rtlpci->rxbuffersize, PCI_DMA_FROMDEVICE);
 
+		if (rtlpriv->use_new_trx_flow)
+			buffer_desc =
+			  &rtlpci->rx_ring[rxring_idx].buffer_desc
+				[rtlpci->rx_ring[rxring_idx].idx];
+
 		/* get a new skb - if fail, old one will be reused */
 		new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
 		if (unlikely(!new_skb))
 			goto no_new;
-		if (rtlpriv->use_new_trx_flow) {
-			buffer_desc =
-			  &rtlpci->rx_ring[rxring_idx].buffer_desc
-				[rtlpci->rx_ring[rxring_idx].idx];
+		if (rtlpriv->use_new_trx_flow)
 			/*means rx wifi info*/
 			pdesc = (struct rtl_rx_desc *)skb->data;
-		}
+
 		memset(&rx_status , 0 , sizeof(rx_status));
 		rtlpriv->cfg->ops->query_rx_desc(hw, &stats,
 						 &rx_status, (u8 *)pdesc, skb);
-- 
2.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-13  2:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-12 11:33 [PATCH] rtlwifi: get buffer_desc before trying to alloc new skb Yang Bai
2015-03-12 16:03 ` Larry Finger
     [not found] ` <1426160036-1542-1-git-send-email-hamo.by-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-03-12 17:29   ` Larry Finger
     [not found]     ` <5501CCFB.3040203-tQ5ms3gMjBLk1uMJSBkQmQ@public.gmane.org>
2015-03-13  2:36       ` Yang Bai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).