public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: "Ethan Tidmore" <ethantidmore06@gmail.com>
To: "Mariyam Shahid" <mariyam.shahid135@gmail.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
Cc: "Michael Straube" <straube.linux@gmail.com>,
	<linux-staging@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] staging: rtl8723bs: use kzalloc_obj() instead of kzalloc()
Date: Tue, 17 Feb 2026 13:04:29 -0600	[thread overview]
Message-ID: <DGHGYT2D00KV.111X709FMZFDE@gmail.com> (raw)
In-Reply-To: <20260217103402.4359-1-mariyam.shahid135@gmail.com>

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

      reply	other threads:[~2026-02-17 20:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DGHGYT2D00KV.111X709FMZFDE@gmail.com \
    --to=ethantidmore06@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mariyam.shahid135@gmail.com \
    --cc=straube.linux@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox