[PATCH 2/7] iio: ssp_sensors: simplify cleanup using __free
Andy Shevchenko
andriy.shevchenko at intel.com
Tue Mar 10 14:11:56 PDT 2026
On Wed, Mar 11, 2026 at 01:35:08AM +0530, Sanjay Chitroda wrote:
>
> 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().
Why this is a series? You can avoid spamming tons of unrelated people with this
by sending patches individually.
...
> case SSP_HUB2AP_WRITE:
> - buffer = kzalloc(length, GFP_KERNEL | GFP_DMA);
> + char *buffer __free(kfree) = kzalloc(length, GFP_KERNEL | GFP_DMA);
> 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;
Now you can return directly.
return ssp_parse_dataframe(data, buffer, length);
But also add a prerequisite to convert to guard()() et alai.
> default:
--
With Best Regards,
Andy Shevchenko
More information about the Linux-mediatek
mailing list