Skip to content

Commit 0a5f411

Browse files
Shyam-sunder-reddygregkh
authored andcommitted
staging: rtl8723bs: os_dep: avoid NULL pointer dereference in rtw_cbuf_alloc
commit bc851db upstream. 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: 980cd42 ("staging: rtl8723bs: replace rtw_zmalloc() with kzalloc()") Cc: stable <stable@kernel.org> Signed-off-by: Shyam Sunder Reddy Padira <shyamsunderreddypadira@gmail.com> Reviewed-by: Dan Carpenter <error27@gmail.com> Link: https://patch.msgid.link/20260414071308.4781-2-shyamsunderreddypadira@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 22788b1 commit 0a5f411

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/staging/rtl8723bs/os_dep/osdep_service.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ struct rtw_cbuf *rtw_cbuf_alloc(u32 size)
194194
struct rtw_cbuf *cbuf;
195195

196196
cbuf = kzalloc_flex(*cbuf, bufs, size);
197-
cbuf->size = size;
197+
if (cbuf)
198+
cbuf->size = size;
198199

199200
return cbuf;
200201
}

0 commit comments

Comments
 (0)