From: Jonathan Cameron <jic23@kernel.org>
To: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
kees@kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/3] iio: ssp_sensors: simplify cleanup using __free
Date: Sun, 15 Mar 2026 18:54:50 +0000 [thread overview]
Message-ID: <20260315185450.4c3fe811@jic23-huawei> (raw)
In-Reply-To: <20260315125509.857195-3-sanjayembedded@gmail.com>
On Sun, 15 Mar 2026 18:25:08 +0530
Sanjay Chitroda <sanjayembeddedse@gmail.com> wrote:
> From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
>
> Replace manual cleanup logic with __free attribute from cleanup.h. This
> removes explicit kfree() calls and simplifies the error handling paths.
>
> No functional change intended for kmalloc().
>
> Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Hi Sanjay
I'd suggest slowing down with new versions. 1 weeks is a usual good minimum
because it avoids what has happened here where you get feedback on a later
version that could have been given on the earlier one and hence
waste both your time and reviewer time (a little).
> ---
> Changes in v3:
> - prepare series to have all respective cleanup API support for the ssp_sensors following input from Andy Shevchenko
> - Link to v2 https://lore.kernel.org/all/20260311174151.3441429-1-sanjayembedded@gmail.com/
> Changes in v2:
> - split series to individual patch
> - address review comment from Andy Shevchenko
> - Link to v1 https://lore.kernel.org/all/20260310200513.2162018-3-sanjayembedded@gmail.com/
> ---
> drivers/iio/common/ssp_sensors/ssp_spi.c | 14 +++-----------
> 1 file changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/iio/common/ssp_sensors/ssp_spi.c b/drivers/iio/common/ssp_sensors/ssp_spi.c
> index 87a38002b218..9df94bd02e3a 100644
> --- a/drivers/iio/common/ssp_sensors/ssp_spi.c
> +++ b/drivers/iio/common/ssp_sensors/ssp_spi.c
> @@ -326,7 +326,6 @@ static int ssp_parse_dataframe(struct ssp_data *data, char *dataframe, int len)
> /* threaded irq */
> int ssp_irq_msg(struct ssp_data *data)
> {
> - char *buffer;
> u8 msg_type;
> int ret;
> u16 length, msg_options;
> @@ -370,7 +369,7 @@ int ssp_irq_msg(struct ssp_data *data)
> * but the slave should not send such ones - it is to
> * check but let's handle this
> */
> - buffer = kmalloc(length, GFP_KERNEL | GFP_DMA);
> + char *buffer __free(kfree) = kmalloc(length, GFP_KERNEL | GFP_DMA);
Andy raised if this is the right thing to do at all I think.
Maybe look at whether there is a simple maximum length and stash a buffer that
gets reused each time instead of a fresh allocation. May well simplify
the code.
> if (!buffer)
> return -ENOMEM;
>
> @@ -379,8 +378,6 @@ int ssp_irq_msg(struct ssp_data *data)
> if (ret >= 0)
> ret = -EPROTO;
>
> - kfree(buffer);
> -
> dev_err(SSP_DEV, "No match error %x\n",
> msg_options);
>
> @@ -411,22 +408,17 @@ int ssp_irq_msg(struct ssp_data *data)
> complete(msg->done);
> break;
> case SSP_HUB2AP_WRITE:
> - buffer = kzalloc(length, GFP_KERNEL | GFP_DMA);
> + char *buffer __free(kfree) = kzalloc(length, GFP_KERNEL | GFP_DMA);
Scope isn't what you think it is...
> if (!buffer)
> return -ENOMEM;
>
> ret = spi_read(data->spi, buffer, length);
> if (ret < 0) {
> dev_err(SSP_DEV, "spi read fail\n");
> - kfree(buffer);
> break;
> }
>
> - ret = ssp_parse_dataframe(data, buffer, length);
> -
> - kfree(buffer);
> - break;
> -
> + return ssp_parse_dataframe(data, buffer, length);
> default:
> dev_err(SSP_DEV, "unknown msg type\n");
> return -EPROTO;
next prev parent reply other threads:[~2026-03-15 18:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-15 12:55 [PATCH v3 0/3] iio: ssp_sensors: improve resource cleanup with cleanup.h Sanjay Chitroda
2026-03-15 12:55 ` [PATCH v3 1/3] iio: ssp_sensors: ssp_spi: use guard() to release mutexes Sanjay Chitroda
2026-03-15 18:52 ` Jonathan Cameron
2026-03-16 14:32 ` Andy Shevchenko
2026-03-26 3:13 ` Sanjay Chitroda
2026-03-15 12:55 ` [PATCH v3 2/3] iio: ssp_sensors: simplify cleanup using __free Sanjay Chitroda
2026-03-15 18:54 ` Jonathan Cameron [this message]
2026-03-15 12:55 ` [PATCH v3 3/3] iio: ssp_sensors: cleanup codestyle warning Sanjay Chitroda
2026-03-15 18:55 ` Jonathan Cameron
2026-03-16 14:34 ` Andy Shevchenko
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=20260315185450.4c3fe811@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=kees@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=sanjayembeddedse@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
all inboxes | Powered by JetHome®