linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Chuang <yhchuang@realtek.com>
To: Chris Chiu <chiu@endlessm.com>
Cc: Kalle Valo <kvalo@codeaurora.org>,
	linux-wireless <linux-wireless@vger.kernel.org>,
	Brian Norris <briannorris@chromium.org>,
	"mikhail.v.gavrilov@gmail.com" <mikhail.v.gavrilov@gmail.com>,
	"rtereguloff@gmail.com" <rtereguloff@gmail.com>
Subject: RE: [PATCH] rtw88: fix potential NULL skb access in TX ISR
Date: Tue, 7 Jan 2020 11:21:26 +0000	[thread overview]
Message-ID: <5ffa570167b34b77ab05cdf490812a59@realtek.com> (raw)
In-Reply-To: <CAB4CAwfxQJzsJfxScVE+Y_xYbdSigTf567b9Xv-LFyQQnOXEAA@mail.gmail.com>

From: Chris Chiu
> Subject: Re: [PATCH] rtw88: fix potential NULL skb access in TX ISR
> 
> On Tue, Jan 7, 2020 at 4:08 PM <yhchuang@realtek.com> wrote:
> >
> > From: Yan-Hsuan Chuang <yhchuang@realtek.com>
> >
> > Sometimes the TX queue may be empty and we could possible
> > dequeue a NULL pointer, crash the kernel. If the skb is NULL
> > then there is nothing to do, just leave the ISR.
> >
> > And the TX queue should not be empty here, so print an error
> > to see if there is anything wrong for DMA ring.
> >
> > Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver")
> > Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
> > ---
> >  drivers/net/wireless/realtek/rtw88/pci.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/net/wireless/realtek/rtw88/pci.c
> b/drivers/net/wireless/realtek/rtw88/pci.c
> > index a58e8276a41a..a6746b5a9ff2 100644
> > --- a/drivers/net/wireless/realtek/rtw88/pci.c
> > +++ b/drivers/net/wireless/realtek/rtw88/pci.c
> > @@ -832,6 +832,11 @@ static void rtw_pci_tx_isr(struct rtw_dev *rtwdev,
> struct rtw_pci *rtwpci,
> >
> >         while (count--) {
> >                 skb = skb_dequeue(&ring->queue);
> > +               if (!skb) {
> > +                       rtw_err(rtwdev, "failed to dequeue %d skb TX
> queue %d, BD=0x%08x, rp %d -> %d\n",
> > +                               count, hw_queue, bd_idx, ring->r.rp,
> cur_rp);
> > +                       break;
> > +               }
> >                 tx_data = rtw_pci_get_tx_data(skb);
> >                 pci_unmap_single(rtwpci->pdev, tx_data->dma,
> skb->len,
> >                                  PCI_DMA_TODEVICE);
> > --
> > 2.17.1
> >
> 
> Maybe we can simply do 'while (count -- &&
> !skb_queue_empty(&ring->queue))' to achieve the same thing?
> I don't think it worths to raise an error unless the count is expected
> to exactly match the queue length in any
> circumstances.
> 

Yes, I expected that the queue length should match with the DMA ring.
And so I printed an error to see why the count mismatched.

Yan-Hsuan

  reply	other threads:[~2020-01-07 11:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07  8:08 [PATCH] rtw88: fix potential NULL skb access in TX ISR yhchuang
2020-01-07 10:40 ` Chris Chiu
2020-01-07 11:21   ` Tony Chuang [this message]
2020-01-09 10:26     ` Chris Chiu
2020-01-26 15:42 ` Kalle Valo

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=5ffa570167b34b77ab05cdf490812a59@realtek.com \
    --to=yhchuang@realtek.com \
    --cc=briannorris@chromium.org \
    --cc=chiu@endlessm.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mikhail.v.gavrilov@gmail.com \
    --cc=rtereguloff@gmail.com \
    /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 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).