[PATCH v2] staging: rtl8723bs: use kzalloc_obj() instead of kzalloc()
From: Mariyam Shahid
Date: Tue Feb 17 2026 - 05:34:16 EST
Replace kzalloc() using sizeof(*ptr) with kzalloc_obj() to improve
type safety. kzalloc_obj() ensures that the size allocated matches
the type of the pointer automatically, which prevents potential
mismatches if the pointer type is ever refactored.
This change cleans up a checkpatch.pl warning:
"Prefer kzalloc_obj over kzalloc with sizeof"
Signed-off-by: Mariyam Shahid <mariyam.shahid135@xxxxxxxxx>
---
v2: Resending now that kzalloc_obj() is available in the tree.
drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 22dc36e8e38a..8cb9a760f763 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -1954,7 +1954,7 @@ signed int rtw_set_key(struct adapter *adapter, struct security_priv *psecurityp
}
if (enqueue) {
- pcmd = kzalloc(sizeof(*pcmd), GFP_KERNEL);
+ pcmd = kzalloc_obj(pcmd, GFP_KERNEL);
if (!pcmd) {
kfree(psetkeyparm);
res = _FAIL; /* try again */
--
2.43.0