From: sashiko-bot@kernel.org
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH v2 7/7] gpiolib: use bitmap_zalloc() for fastpath bitmaps
Date: Wed, 04 Nov 2026 03:50:46 +0000 [thread overview]
Message-ID: <sashiko-outbox-196638@kernel.org> (raw)
In-Reply-To: <20261103-b4-gpiolib-free-v2-7-ea46767c9cf8@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] gpiolib: define and initialize __free() variable in gpio_descs_alloc()
--
commit 014858138dec2ff00e5cb0fd3fa050587447ef44
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
gpiolib: use bitmap_zalloc() for fastpath bitmaps
This commit converts invert_mask in struct gpio_array to a pointer and
allocates the get_mask, set_mask, and invert_mask fastpath bitmaps
individually via bitmap_zalloc() instead of a single combined kzalloc()
with manual pointer arithmetic.
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index cf311c1a707c9..bba4e5bb125f9 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -5208,13 +5208,28 @@ static void gpiochip_free_hogs(struct gpio_chip *gc)
[ ... ]
> +static struct gpio_descs *gpio_descs_alloc(unsigned int count,
> + struct gpio_desc *first_desc)
> {
> struct gpio_device *gdev = gpiod_to_gpio_device(first_desc);
> + struct gpio_descs *descs __free(gpiod_put_array) = NULL;
> struct gpio_array *array_info;
> - struct gpio_descs *descs;
> size_t descs_size, alloc_size;
> - unsigned int bitmap_size;
> + unsigned int nbits;
>
> /*
> * If pin hardware number of array member 0 is also 0, select
> @@ -5224,25 +5239,36 @@ static struct gpio_descs *gpio_descs_alloc(unsigned int count, struct gpio_desc
> return kzalloc_flex(*descs, desc, count);
>
> descs_size = struct_size(descs, desc, count);
> - bitmap_size = BITS_TO_LONGS(max(gdev->ngpio, count));
> - alloc_size = descs_size + struct_size(array_info, invert_mask, 3 * bitmap_size);
> + alloc_size = descs_size + sizeof(*array_info);
>
> descs = kzalloc(alloc_size, GFP_KERNEL);
[Severity: Low]
This isn't a bug, but cleanup.h conventions prefer defining and initializing
__free() variables in a single statement rather than declaring them as NULL
at the top of the function and assigning them later.
In gpio_descs_alloc(), could descs be defined and initialized directly at the
kzalloc() call site after computing descs_size (using struct_size_t(struct
gpio_descs, desc, count)) and alloc_size?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103-b4-gpiolib-free-v2-0-ea46767c9cf8@gmail.com?part=7
next prev parent reply other threads:[~2026-11-04 3:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 3:40 [PATCH v2 0/7] gpiolib: scope-based management and cleanup for GPIO descriptor arrays Dmitry Torokhov
2026-11-04 3:40 ` [PATCH v2 1/7] gpiolib: fix GPIO descriptor leak in gpiod_get_array() Dmitry Torokhov
2026-11-04 12:06 ` Andy Shevchenko
2026-11-04 12:08 ` Andy Shevchenko
2026-11-04 3:40 ` [PATCH v2 2/7] gpiolib: fix fast-path cancellation " Dmitry Torokhov
2026-11-04 12:09 ` Andy Shevchenko
2026-11-04 3:40 ` [PATCH v2 3/7] gpiolib: of: return -ENOENT from of_gpio_count() stub Dmitry Torokhov
2026-11-04 12:07 ` Andy Shevchenko
2026-11-04 3:40 ` [PATCH v2 4/7] gpiolib: add support for scope-based management of GPIO descriptors Dmitry Torokhov
2026-11-04 12:10 ` Andy Shevchenko
2026-11-04 3:40 ` [PATCH v2 5/7] gpiolib: use __free(gpiod_put_array) in gpiod_get_array() Dmitry Torokhov
2026-11-04 12:13 ` Andy Shevchenko
2026-11-04 3:40 ` [PATCH v2 6/7] gpiolib: avoid krealloc() " Dmitry Torokhov
2026-11-04 3:48 ` sashiko-bot
2026-11-04 14:23 ` Bartosz Golaszewski
2026-11-04 17:13 ` Dmitry Torokhov
2026-11-04 12:20 ` Andy Shevchenko
2026-11-04 18:14 ` Dmitry Torokhov
2026-11-04 21:40 ` Andy Shevchenko
2026-11-04 21:51 ` Dmitry Torokhov
2026-11-04 22:05 ` Andy Shevchenko
2026-11-04 3:40 ` [PATCH v2 7/7] gpiolib: use bitmap_zalloc() for fastpath bitmaps Dmitry Torokhov
2026-11-04 3:50 ` sashiko-bot [this message]
2026-11-04 17:14 ` Dmitry Torokhov
2026-11-04 12:17 ` 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=sashiko-outbox-196638@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-gpio@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.