* [PATCH v2] staging: rtl8723bs: use kzalloc_obj() instead of kzalloc()
@ 2026-02-17 10:34 Mariyam Shahid
2026-02-17 19:04 ` Ethan Tidmore
0 siblings, 1 reply; 2+ messages in thread
From: Mariyam Shahid @ 2026-02-17 10:34 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Michael Straube, linux-staging, linux-kernel, Mariyam Shahid
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@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] staging: rtl8723bs: use kzalloc_obj() instead of kzalloc()
2026-02-17 10:34 [PATCH v2] staging: rtl8723bs: use kzalloc_obj() instead of kzalloc() Mariyam Shahid
@ 2026-02-17 19:04 ` Ethan Tidmore
0 siblings, 0 replies; 2+ messages in thread
From: Ethan Tidmore @ 2026-02-17 19:04 UTC (permalink / raw)
To: Mariyam Shahid, Greg Kroah-Hartman
Cc: Michael Straube, linux-staging, linux-kernel
On Tue Feb 17, 2026 at 4:34 AM CST, Mariyam Shahid wrote:
> 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@gmail.com>
> ---
>
> v2: Resending now that kzalloc_obj() is available in the tree.
>
Just updated my staging-next tree and kzalloc_obj() isn't there? Make
sure you're using staging-next when creating patches for staging.
> 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);
You still need to dereference pcmd here or this doesn't compile. Please
at least compile test your patches before sending them off.
Thanks,
ET
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-17 20:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-17 10:34 [PATCH v2] staging: rtl8723bs: use kzalloc_obj() instead of kzalloc() Mariyam Shahid
2026-02-17 19:04 ` Ethan Tidmore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox