public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Ravi Kumar kairi <kumarkairiravi@gmail.com>
Cc: dpenkler@gmail.com, gregkh@linuxfoundation.org, kuba@kernel.org,
	rmk+kernel@armlinux.org.uk, broonie@kernel.org, arnd@arndb.de,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] [PATCH 2/2] staging:glib:hp_82335: Refactor kzalloc size calculation to use pointer dereference
Date: Tue, 18 Feb 2025 16:04:24 +0300	[thread overview]
Message-ID: <43545be2-bde2-4d15-82fa-282698d599df@stanley.mountain> (raw)
In-Reply-To: <b3358e0d2c50a7d0777dd11d6e34ed9a52c00377.1739794938.git.kumarkairiravi@gmail.com>

On Mon, Feb 17, 2025 at 06:26:17PM +0530, Ravi Kumar kairi wrote:
> From: Ravi Kumar Kairi <kumarkairiravi@gmail.com>
> 
> Replaced sizeof(struct hp82335_priv) with sizeof(*board->private_data)
> *as checkpatch* suggested.
> 
> Signed-off-by: Ravi Kumar Kairi <kumarkairiravi@gmail.com>
> ---
>  drivers/staging/gpib/hp_82335/hp82335.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/gpib/hp_82335/hp82335.c b/drivers/staging/gpib/hp_82335/hp82335.c
> index f1c2045570..66557d6964 100644
> --- a/drivers/staging/gpib/hp_82335/hp82335.c
> +++ b/drivers/staging/gpib/hp_82335/hp82335.c
> @@ -205,7 +205,7 @@ static gpib_interface_t hp82335_interface = {
>  
>  static int hp82335_allocate_private(gpib_board_t *board)
>  {
> -	board->private_data = kzalloc(sizeof(struct hp82335_priv), GFP_KERNEL);
> +	board->private_data = kzalloc(sizeof(*board->private_data), GFP_KERNEL);

No, this doesn't work.  board->private_data is a void pointer.

I recently wrote a Smatch check for this kind of bug, but I was letting
someone send all the fixes before I publish it.

regards,
dan carpenter


  reply	other threads:[~2025-02-18 13:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-17 12:56 [PATCH 0/2] staging:gpib: Fix error message formatting and adjust memory allocation style Ravi Kumar kairi
2025-02-17 12:56 ` [PATCH 1/2] [PATCH 1/2] staging:gpib:hp_82335: Fix error message format for invalid base IO address Ravi Kumar kairi
2025-02-17 12:56 ` [PATCH 2/2] [PATCH 2/2] staging:glib:hp_82335: Refactor kzalloc size calculation to use pointer dereference Ravi Kumar kairi
2025-02-18 13:04   ` Dan Carpenter [this message]
2025-02-19 15:52 ` [PATCH 0/2] staging:gpib: Fix error message formatting and adjust memory allocation style Greg KH
2025-02-19 17:04   ` Ravi Kumar Kairi

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=43545be2-bde2-4d15-82fa-282698d599df@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=dpenkler@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=kumarkairiravi@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=rmk+kernel@armlinux.org.uk \
    /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