From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: nika bakuradze <nbakuradze28@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Khushal Chitturi <khushalchitturi@gmail.com>,
Archit Anant <architanant5@gmail.com>,
Minu Jin <s9430939@naver.com>, Kees Cook <kees@kernel.org>,
Hans de Goede <hansg@kernel.org>,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8723bs: core: avoid NULL pointer dereference in c2h_wk_callback
Date: Tue, 9 Jun 2026 21:05:07 +0300 [thread overview]
Message-ID: <aihV0187aqMh_rMA@ashevche-desk.local> (raw)
In-Reply-To: <CAHyzTT3R-cOpJdE=hKPGSBSdC-BiY29y40DURvKjCN4V+w5EAg@mail.gmail.com>
On Tue, Jun 09, 2026 at 08:40:39PM +0400, nika bakuradze wrote:
First of all, do not top-post!
> You're right, kmalloc(16) effectively won't fail. This is my first
> kernel patch so I was being overcautious with the framing.
>
> Should I resend v2 with the else continue form you suggested,
> or drop the patch entirely?
To some extent the patch makes sense (at least for you to train your skills in
Linux kernel processes, et cetera). I would go with the v2 that uses my approach.
Also drop Fixes tag, consider this as an improvement to make code robust.
> On Tue, Jun 9, 2026 at 11:15 AM Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > On Mon, Jun 08, 2026 at 11:06:58PM +0400, Nikoloz Bakuradze wrote:
> > > c2h_wk_callback() allocates a 16-byte buffer with kmalloc(GFP_ATOMIC)
> > > when the c2h event needs to be read by the host. The existing guard
> > > only wraps the read step, so on allocation failure the loop body falls
> > > through with a NULL c2h_evt and dereferences it in rtw_hal_c2h_valid()
> > > (via c2h_evt_valid() which reads buf->id).
> > >
> > > Restructure the check into an early continue so the rest of the loop
> > > iteration cannot be reached with a NULL pointer.
> >
> >
> > Not sure if we need any Fixes tag. kmalloc(16) won't ever fail (otherwise
> > the system is already in the state when nothing can help).
...
> > > c2h_evt = kmalloc(16, GFP_ATOMIC);
> > > - if (c2h_evt) {
> > > - /* This C2H event is not read, read & clear now */
> > > - if (c2h_evt_read_88xx(adapter, c2h_evt) != _SUCCESS) {
> > > - kfree(c2h_evt);
> > > - continue;
> > > - }
> >
> > > + if (!c2h_evt)
> > > + continue;
> > > + /* This C2H event is not read, read & clear now */
> > > + if (c2h_evt_read_88xx(adapter, c2h_evt) != _SUCCESS) {
> > > + kfree(c2h_evt);
> > > + continue;
> >
> > It's too verbose way of saying
> >
> > } else
> > continue;
> >
> > here.
> >
> > > }
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-06-09 18:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 19:06 Nikoloz Bakuradze
2026-06-09 7:14 ` Andy Shevchenko
2026-06-09 16:40 ` nika bakuradze
2026-06-09 18:05 ` Andy Shevchenko [this message]
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=aihV0187aqMh_rMA@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=architanant5@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=kees@kernel.org \
--cc=khushalchitturi@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=nbakuradze28@gmail.com \
--cc=s9430939@naver.com \
--cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®