From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Nikoloz 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 10:14:54 +0300 [thread overview]
Message-ID: <aie9bqpiNDJ_IU0M@ashevche-desk.local> (raw)
In-Reply-To: <20260608190700.85755-1-nbakuradze28@gmail.com>
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
next prev parent reply other threads:[~2026-06-09 7:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 19:06 [PATCH] staging: rtl8723bs: core: avoid NULL pointer dereference in c2h_wk_callback Nikoloz Bakuradze
2026-06-09 7:14 ` Andy Shevchenko [this message]
2026-06-09 16:40 ` nika bakuradze
2026-06-09 18:05 ` Andy Shevchenko
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=aie9bqpiNDJ_IU0M@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