From: Shyam Sunder Reddy Padira <shyamsunderreddypadira@gmail.com>
To: gregkh@linuxfoundation.org, --to=ethantidmore06@gmail.com
Cc: nayana.mariyappa@gmail.com, s9430939@naver.com,
andriy.shevchenko@intel.com, kees@kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Shyam Sunder Reddy Padira <shyamsunderreddypadira@gmail.com>
Subject: [PATCH v2] staging: rtl8723bs: os_dep: avoid NULL pointer dereference in rtw_cbuf_alloc
Date: Tue, 14 Apr 2026 04:14:17 +0530 [thread overview]
Message-ID: <20260413224417.5674-2-shyamsunderreddypadira@gmail.com> (raw)
In-Reply-To: <DHSBOBFQ3HZK.39HN9XAYE4BT1@gmail.com>
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.
Fixes: 980cd426a25747daf8ed25e2a1904b2d26ffbb3d ("staging: rtl8723bs: replace rtw_zmalloc() with kzalloc()")
Signed-off-by: Shyam Sunder Reddy Padira <shyamsunderreddypadira@gmail.com>
---
changes in v2:
-Fixed spelling mistakes(dereference, potential)
-Added Fixes tag
---
drivers/staging/rtl8723bs/os_dep/osdep_service.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
index 7959daeabc6f..4cfdf7c62344 100644
--- 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;
}
--
2.43.0
next prev parent reply other threads:[~2026-04-13 22:47 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 ` Shyam Sunder Reddy Padira [this message]
[not found] ` <CALx+fbZ_K3C2sTWY_HigceJcp414OEhyEQLGTDEfNnU2q_zKiA@mail.gmail.com>
2026-04-13 23:57 ` [PATCH v2] staging: rtl8723bs: os_dep: avoid NULL pointer dereference " 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
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=20260413224417.5674-2-shyamsunderreddypadira@gmail.com \
--to=shyamsunderreddypadira@gmail.com \
--cc=--to=ethantidmore06@gmail.com \
--cc=andriy.shevchenko@intel.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 \
/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