All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Mariyam Shahid <mariyam.shahid135@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Michael Straube <straube.linux@gmail.com>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8723bs: use kzalloc_obj() instead of kzalloc()
Date: Thu, 19 Feb 2026 11:15:29 +0300	[thread overview]
Message-ID: <aZbGoaG30SE6Cv3F@stanley.mountain> (raw)
In-Reply-To: <20260216161733.7704-1-mariyam.shahid135@gmail.com>

On Mon, Feb 16, 2026 at 09:17:33PM +0500, 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>
> ---
>  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);

This introduces a bug.  It should be kzalloc_obj(*pcmd with an asterisk.
Also there are several other conversions which are possible in this
file...

regards,
dan carpenter


  parent reply	other threads:[~2026-02-19  8:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-16 16:17 [PATCH] staging: rtl8723bs: use kzalloc_obj() instead of kzalloc() Mariyam Shahid
2026-02-17  1:07 ` Ethan Tidmore
2026-02-17  9:12   ` Mariyam Shahid
2026-02-19  8:15 ` Dan Carpenter [this message]
2026-02-20  7:03   ` Mariyam Shahid
2026-02-21 11:10     ` [PATCH v3] staging: rtl8723bs: Replace kzalloc with kzalloc_obj Mariyam Shahid
2026-02-21 18:29       ` Ethan Tidmore
2026-02-22 16:20       ` [PATCH v4] " Mariyam Shahid
2026-02-22 16:42         ` Greg KH
2026-02-23 16:37           ` Mariyam Shahid
2026-02-23  5:35         ` Dan Carpenter

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=aZbGoaG30SE6Cv3F@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.