public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8723bs: os_dep: avoid NULL pointer derefernece in rtw_cbuf_alloc
@ 2026-04-13 18:08 Shyam Sunder Reddy Padira
  2026-04-13 20:51 ` Ethan Tidmore
  0 siblings, 1 reply; 16+ messages in thread
From: Shyam Sunder Reddy Padira @ 2026-04-13 18:08 UTC (permalink / raw)
  To: gregkh
  Cc: nayana.mariyappa, s9430939, andriy.shevchenko, kees,
	linux-staging, linux-kernel, Shyam Sunder Reddy Padira

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 potiental NULL pointer dereference if the
allocation fails.

Signed-off-by: Shyam Sunder Reddy Padira <shyamsunderreddypadira@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-04-14  9:29 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox