Skip to contentSkip to conversation

staging: rtl8723bs: core: avoid NULL pointer dereference in c2h_wk_callback

PATCH In review Nikoloz Bakuradze 2 participants 2 messages Jun 10 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: rtl8723bs: core: avoid NULL pointer dereference in c2h_wk_callback

kmalloc(16, GFP_ATOMIC) in c2h_wk_callback() could in theory return2 NULL, which would then be dereferenced in rtw_hal_c2h_valid().

A 16-byte allocation effectively cannot fail in practice, but add an else continue; to the guard so the failure path exits the iteration cleanly to make the code more robust.

---
Changes in v2:
- Dropped Fixes:/Cc:stable per Andy's review (kmalloc(16) effectively cannot fail in practice).
- Switched to Andy's else continue; form inside the existing if (c2h_evt) block.

 drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/staging/rtl8723bs/core/rtw_cmd.c +2 -0
index c1185c25ed369..8d06b9d0e9bbc 100644
@@ -1708,6 +1708,8 @@ static void c2h_wk_callback(struct work_struct *work)
 					kfree(c2h_evt);
 					continue;
 				}
+			} else {
+				continue;
 			}
 		}
 
Signature · 1 line
2.54.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Nikoloz Bakuradze

kmalloc(16, GFP_ATOMIC) in c2h_wk_callback() could in theory return2 NULL, which would then be dereferenced in rtw_hal_c2h_valid().

A 16-byte allocation effectively cannot fail in practice, but add an else continue; to the guard so the failure path exits the iteration cleanly to make the code more robust.

OK.

Signature · 2 lines
With Best Regards,
Andy Shevchenko