]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
staging: rtl8723bs: os_dep: avoid NULL pointer dereference in rtw_cbuf_alloc
authorShyam Sunder Reddy Padira <shyamsunderreddypadira@gmail.com>
Tue, 14 Apr 2026 07:13:06 +0000 (12:43 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 May 2026 09:36:47 +0000 (11:36 +0200)
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: 980cd426a257 ("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>
drivers/staging/rtl8723bs/os_dep/osdep_service.c

index 7959daeabc6ff01bde2e4548442f55f9b25abccd..4cfdf7c623440a5b69080a500e70c767a7452ddd 100644 (file)
@@ -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;
 }