CVE-2026-46305
Description
In the Linux kernel, the following vulnerability has been resolved:
staging: rtl8723bs: os_dep: avoid NULL pointer dereference in rtw_cbuf_alloc
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.
Affected products
2Patches
40a5f411becfbstaging: rtl8723bs: os_dep: avoid NULL pointer dereference in rtw_cbuf_alloc
1 file changed · +2 −2
drivers/staging/rtl8723bs/os_dep/osdep_service.c+2 −2 modifieddiff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c index 7959daeabc6ff..4cfdf7c623440 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; } -- cgit 1.3-korg
bc851db06045staging: rtl8723bs: os_dep: avoid NULL pointer dereference in rtw_cbuf_alloc
1 file changed · +2 −2
drivers/staging/rtl8723bs/os_dep/osdep_service.c+2 −2 modifieddiff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c index 7959daeabc6ff..4cfdf7c623440 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; } -- cgit 1.3-korg
0a5f411becfbstaging: rtl8723bs: os_dep: avoid NULL pointer dereference in rtw_cbuf_alloc
1 file changed · +2 −2
drivers/staging/rtl8723bs/os_dep/osdep_service.c+2 −2 modifieddiff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c index 7959daeabc6ff..4cfdf7c623440 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; } -- cgit 1.3-korg
bc851db06045staging: rtl8723bs: os_dep: avoid NULL pointer dereference in rtw_cbuf_alloc
1 file changed · +2 −2
drivers/staging/rtl8723bs/os_dep/osdep_service.c+2 −2 modifieddiff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c index 7959daeabc6ff..4cfdf7c623440 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; } -- cgit 1.3-korg
Vulnerability mechanics
Root cause
"The return value of a memory allocation function is dereferenced without checking if the allocation succeeded."
Attack vector
An attacker can trigger this vulnerability by causing the `rtw_cbuf_alloc` function to fail its memory allocation. This failure leads to a NULL pointer dereference when the code attempts to access members of the unallocated structure. The specific conditions that cause `kzalloc_flex()` to fail are not detailed in the provided patches.
Affected code
The vulnerability exists in the `rtw_cbuf_alloc` function within the file `drivers/staging/rtl8723bs/os_dep/osdep_service.c`. The issue stems from the unconditional dereferencing of the `cbuf` pointer after the `kzalloc_flex()` call.
What the fix does
The patch adds a check to ensure that the pointer returned by `kzalloc_flex()` is not NULL before attempting to access its members. If the allocation fails and `cbuf` is NULL, the `cbuf->size = size;` assignment is skipped, preventing the NULL pointer dereference. This change guards the access to the allocated structure, thereby mitigating the vulnerability [patch_id=5239794].
Generated on Jun 8, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
2News mentions
1- Linux Kernel: 25 Vulnerabilities Disclosed in Single Batch on June 8, 2026Vypr Intelligence · Jun 8, 2026