Re: [PATCH v2 5/7] gpiolib: use __free(gpiod_put_array) in gpiod_get_array()
From: Andy Shevchenko
Date: Wed Nov 04 2026 - 07:14:00 EST
On Tue, Nov 03, 2026 at 07:40:33PM -0800, Dmitry Torokhov wrote:
> Switch to using __free(gpiod_put_array) scope-based cleanup facility
> in gpiod_get_array(), simplifying error unwinding and eliminating manual
> gpiod_put_array() calls.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
...
> - descs_size = struct_size(descs, desc, count);
> - descs = kzalloc(descs_size, GFP_KERNEL);
> + struct gpio_descs *descs __free(gpiod_put_array) =
> + kzalloc_flex(*descs, desc, count);
I believe in this case one line is also allowed.
struct gpio_descs *descs __free(gpiod_put_array) = kzalloc_flex(*descs, desc, count);
> if (!descs)
> return ERR_PTR(-ENOMEM);
...
> if (i == 0 && gpiod_hwgpio(desc) == 0) {
> struct gpio_descs *array;
> + size_t descs_size = struct_size(descs, desc, count);
Reversed xmas tree order?
--
With Best Regards,
Andy Shevchenko