From: Dan Carpenter <error27@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Shyam Sunder Reddy Padira <shyamsunderreddypadira@gmail.com>,
gregkh@linuxfoundation.org, ethantidmore06@gmail.com,
nayana.mariyappa@gmail.com, s9430939@naver.com, kees@kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] staging: rtl8723bs: os_dep: avoid NULL pointer dereference in rtw_cbuf_alloc
Date: Tue, 14 Apr 2026 11:00:02 +0300 [thread overview]
Message-ID: <ad30An8Oi_D-UTB2@stanley.mountain> (raw)
In-Reply-To: <ad3zDOhTjfwy_vj9@stanley.mountain>
On Tue, Apr 14, 2026 at 10:55:56AM +0300, Dan Carpenter wrote:
> On Tue, Apr 14, 2026 at 10:46:13AM +0300, Andy Shevchenko wrote:
> > On Tue, Apr 14, 2026 at 12:43:06PM +0530, Shyam Sunder Reddy Padira wrote:
> > > The return value of kzalloc_flex() is used without
> > > ensuring that the allocation succeeded, and the
> > > pointer is dereferenced unconditionally.
> > >
> > > Guard the access to the allocated structure to
> > > avoid a potential NULL pointer dereference if the
> > > allocation fails.
> >
> > You have a procedural issue here: please avoid sending a new patch version in
> > the same email thread. It makes things harder to follow. For example, I usually
> > mark the entire thread as read if I see some comments and don't want to go into
> > the details. It effectively means that I will never see the new version that
> > already was in the same thread!
> >
> > ...
> >
> > > --- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c
> > > +++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
> > > @@ -194,7 +194,8 @@ struct rtw_cbuf *rtw_cbuf_alloc(u32 size)
> > > struct rtw_cbuf *cbuf;
> > >
> > > cbuf = kzalloc_flex(*cbuf, bufs, size);
> > > - cbuf->size = size;
> > > + if (cbuf)
> > > + cbuf->size = size;
> > >
> > > return cbuf;
> >
> > Now to the code. This is still buggy. The problem is that the size is not
> > validated and when it's 0, the same issue (dereference of invalid pointer)
> > will happen.
> >
> > Dan, JFYI k*alloc*(0) returns not NULL and not valid pointer.
>
> kzalloc_flex() basically can't return the ZERO_SIZE pointer.
I meant ZERO_SIZE_PTR.
regards,
dan carpenter
next prev parent reply other threads:[~2026-04-14 8:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 18:08 [PATCH] staging: rtl8723bs: os_dep: avoid NULL pointer derefernece in rtw_cbuf_alloc Shyam Sunder Reddy Padira
2026-04-13 20:51 ` Ethan Tidmore
2026-04-13 22:44 ` [PATCH v2] staging: rtl8723bs: os_dep: avoid NULL pointer dereference " Shyam Sunder Reddy Padira
[not found] ` <CALx+fbZ_K3C2sTWY_HigceJcp414OEhyEQLGTDEfNnU2q_zKiA@mail.gmail.com>
2026-04-13 23:57 ` Shyam Sunder Reddy Padira
2026-04-14 5:59 ` Dan Carpenter
2026-04-14 7:42 ` Andy Shevchenko
2026-04-14 7:13 ` [PATCH v3] " Shyam Sunder Reddy Padira
2026-04-14 7:19 ` Dan Carpenter
2026-04-14 7:46 ` Andy Shevchenko
2026-04-14 7:55 ` Dan Carpenter
2026-04-14 8:00 ` Dan Carpenter [this message]
2026-04-14 8:20 ` Andy Shevchenko
2026-04-14 8:33 ` Dan Carpenter
2026-04-14 8:44 ` Andy Shevchenko
2026-04-14 8:47 ` Andy Shevchenko
2026-04-14 9:09 ` Dan Carpenter
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=ad30An8Oi_D-UTB2@stanley.mountain \
--to=error27@gmail.com \
--cc=andriy.shevchenko@intel.com \
--cc=ethantidmore06@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=nayana.mariyappa@gmail.com \
--cc=s9430939@naver.com \
--cc=shyamsunderreddypadira@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 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.