From: Larry Finger <Larry.Finger@lwfinger.net>
To: Yang Bai <hamo.by@gmail.com>,
chaoming_li@realsil.com.cn, kvalo@codeaurora.org
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rtlwifi: get buffer_desc before trying to alloc new skb
Date: Thu, 12 Mar 2015 11:03:01 -0500 [thread overview]
Message-ID: <5501B8B5.2010801@lwfinger.net> (raw)
In-Reply-To: <1426160036-1542-1-git-send-email-hamo.by@gmail.com>
On 03/12/2015 06:33 AM, Yang Bai wrote:
> 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>
Good catch. The only problem that I have is this fix adds even more branching to
this interrupt routine. At first glance, I should be able to set buffer_desc in
the earlier code where the code has already branched. For testing, an RTL8192EE
card will be needed. Do you have such a card?
Larry
> ---
> 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);
>
next prev parent reply other threads:[~2015-03-12 16:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2015-03-12 17:29 ` Larry Finger
2015-03-12 17:29 ` Larry Finger
2015-03-13 2:36 ` Yang Bai
2015-03-13 2:36 ` Yang Bai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5501B8B5.2010801@lwfinger.net \
--to=larry.finger@lwfinger.net \
--cc=chaoming_li@realsil.com.cn \
--cc=hamo.by@gmail.com \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.