Commit bc851db0 authored by Shyam Sunder Reddy Padira's avatar Shyam Sunder Reddy Padira Committed by Greg Kroah-Hartman
Browse files

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.

Fixes: 980cd426 ("staging: rtl8723bs: replace rtw_zmalloc() with kzalloc()")
Cc: stable <stable@kernel.org>
Signed-off-by: default avatarShyam Sunder Reddy Padira <shyamsunderreddypadira@gmail.com>
Reviewed-by: default avatarDan Carpenter <error27@gmail.com>
Link: https://patch.msgid.link/20260414071308.4781-2-shyamsunderreddypadira@gmail.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 32c91e8e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -194,6 +194,7 @@ struct rtw_cbuf *rtw_cbuf_alloc(u32 size)
	struct rtw_cbuf *cbuf;

	cbuf = kzalloc_flex(*cbuf, bufs, size);
	if (cbuf)
		cbuf->size = size;

	return cbuf;