public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Ron Li <xiangrongl@nvidia.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	vadimp@nvidia.com,  alok.a.tiwari@oracle.com,
	kblaiech@nvidia.com, davthompson@nvidia.com,
	 platform-driver-x86@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 4/4] platform/mellanox/mlxbf_pka: add __free(kfree) to handle memory allocation
Date: Tue, 12 Aug 2025 12:47:44 +0300 (EEST)	[thread overview]
Message-ID: <d4c48d92-e064-c050-d275-2d03f320c98b@linux.intel.com> (raw)
In-Reply-To: <20250811153934.671070-5-xiangrongl@nvidia.com>

On Mon, 11 Aug 2025, Ron Li wrote:

> Used __free(kfree) attribute to call kzalloc for allocating the 'data'

Hi Ron,

Grammar problems, but this patch won't be necessary, see below.

> variable in mlxbf_pka_drv_ring_ioctl(). So that the variable can be
> released automatically.
> 
> Reviewed-by: David Thompson <davthompson@nvidia.com>
> Reviewed-by: Khalil Blaiech <kblaiech@nvidia.com>
> Signed-off-by: Ron Li <xiangrongl@nvidia.com>
> ---
>  drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_drv.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_drv.c b/drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_drv.c
> index 0f93c1aa7130..2dd773ec1dc3 100644
> --- a/drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_drv.c
> +++ b/drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_drv.c
> @@ -3,12 +3,14 @@
>  
>  #include <linux/acpi.h>
>  #include <linux/cdev.h>
> +#include <linux/cleanup.h>
>  #include <linux/device.h>
>  #include <linux/hw_random.h>
>  #include <linux/idr.h>
>  #include <linux/interrupt.h>
>  #include <linux/iommu.h>
>  #include <linux/ioport.h>
> +#include <linux/kdev_t.h>
>  #include <linux/kernel.h>
>  #include <linux/miscdevice.h>
>  #include <linux/module.h>
> @@ -438,7 +440,6 @@ static long mlxbf_pka_drv_ring_ioctl(void *device_data, unsigned int cmd, unsign
>  		struct mlxbf_pka_dev_shim_s *shim;
>  		bool trng_present;
>  		u32 byte_cnt;
> -		u32 *data;
>  		int ret;
>  
>  		shim = ring_dev->ring->shim;
> @@ -456,25 +457,21 @@ static long mlxbf_pka_drv_ring_ioctl(void *device_data, unsigned int cmd, unsign
>  		 */
>  		byte_cnt = round_up(trng_data.count, MLXBF_PKA_TRNG_OUTPUT_CNT);
>  
> -		data = kzalloc(byte_cnt, GFP_KERNEL);
> +		u32 *data __free(kfree) = kzalloc(byte_cnt, GFP_KERNEL);
>  		if (!data)
>  			return -ENOMEM;
>  
>  		trng_present = mlxbf_pka_dev_has_trng(shim);
> -		if (!trng_present) {
> -			kfree(data);
> +		if (!trng_present)
>  			return -EAGAIN;
> -		}
>  
>  		ret = mlxbf_pka_dev_trng_read(shim, data, byte_cnt);
>  		if (ret) {
>  			dev_dbg(ring_dev->device, "TRNG failed %d\n", ret);
> -			kfree(data);
>  			return ret;
>  		}
>  
>  		ret = copy_to_user((void __user *)(trng_data.data), data, trng_data.count);
> -		kfree(data);
>  		return ret ? -EFAULT : 0;
>  	}

Please make the code to use the up-to-date conventions right from the 
start. We try to avoid changing same lines back and forth within the same 
series.

In general, anything newly introduced should use the most recent 
conventions. I might occassionally allow exceptions to this rule for 
a pre-existing file to remain consistent within that file but that
won't apply here.

-- 
 i.


      reply	other threads:[~2025-08-12  9:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-11 15:39 [PATCH v2 0/4] platform/mellanox: Add mlxbf_pka driver for BlueField DPU Ron Li
2025-08-11 15:39 ` [PATCH v2 1/4] platform/mellanox/mlxbf_pka: " Ron Li
2025-08-12 10:52   ` Ilpo Järvinen
2025-08-11 15:39 ` [PATCH v2 2/4] platform/mellanox/mlxbf_pka: add guard() and scoped_guard() Ron Li
2025-08-11 15:39 ` [PATCH v2 3/4] platform/mellanox/mlxbf_pka: add devm_mutex_init() to initialize mutex Ron Li
2025-08-11 15:39 ` [PATCH v2 4/4] platform/mellanox/mlxbf_pka: add __free(kfree) to handle memory allocation Ron Li
2025-08-12  9:47   ` Ilpo Järvinen [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=d4c48d92-e064-c050-d275-2d03f320c98b@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=alok.a.tiwari@oracle.com \
    --cc=davthompson@nvidia.com \
    --cc=hdegoede@redhat.com \
    --cc=kblaiech@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=vadimp@nvidia.com \
    --cc=xiangrongl@nvidia.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