From: Kent Gibson <warthog618@gmail.com>
To: Adrian Ambrozewicz <aambrozewicz@nvidia.com>
Cc: Bartosz Golaszewski <brgl@kernel.org>, linux-gpio@vger.kernel.org
Subject: Re: [PATCH] gpiolib: cdev: don't record a line direction the driver refused
Date: Fri, 16 Oct 2026 16:37:09 +0800 [thread overview]
Message-ID: <20261016083709.GA56522@rigel> (raw)
In-Reply-To: <20261016074704.1860749-9-aambrozewicz@nvidia.com>
> gpiod_free_commit() does the same read-modify-write: it reads the
> flags, calls ->free(), which may sleep, and writes the word back.
> Patch 8 of chip-removal v2 (for the debounce race Sashiko found on the
> event clock fix) relies on that write: it resets debounce_period_us
> first and makes the write a release store, pairing with the
> test_and_set_bit() in gpiod_request_commit(), so that a new owner sees
> the reset. With atomic bitops there, clearing GPIOD_FLAG_REQUESTED last
> with clear_bit_unlock() would give the same ordering. v2 keeps the
> release store, as that matches the code today.
>
> v2 of this patch only drops the GPIOD_FLAG_IS_OUT lines from
> gpio_v2_line_config_flags_to_desc_flags(), which b7adfb6076ff also
> touches, so a revert and this patch only need rebasing over each other.
>
> > > >> Doesn't this bypass the bitmap_free() calls at the end of the function and
> > > >> leak mask and bits?
> > > >
> > > > This also looks like a valid concern in existing code. Unlikely, but valid.
> > > >
> > > > It is also not something we can readily test.
>
> It is: both the -EPERM return and the one after a failed
> gpiochip_set_multiple() skip the bitmap_free() calls when the bitmaps
> were allocated. The -EPERM path shows up with gpio-sim as it is: on a
> chip with more lines than CONFIG_GPIOLIB_FASTPATH_LIMIT (512 by
> default; I used 600), GPIO_V2_LINE_SET_VALUES_IOCTL on a line requested
> as input leaves the two bitmaps to kmemleak.
I was thinking specifically of the gpiochip_set_multiple() error path.
How do you elicit a gpiochip_set_multiple() failure from gpio-sim -
it always returns 0?
> Unless Bart would rather take it
> himself, I'll send the fix as patch 7 of chip-removal v2:
>
Oh nuts, I overlooked the EPERM case.
Bart has already merged a patch for the gpiod_set_multiple() failure leak[1]
- you were Cced.
I would keep patches in your removal series focused on that and keep
patches for existing problems separate so we can get that series merged as
soon as possible.
I'll send out a patch for the EPERM path shortly.
Cheers,
Kent.
[1] https://lore.kernel.org/linux-gpio/179206624090.9766.14775829225106044242.b4-ty@oss.qualcomm.com/T/#t
next prev parent reply other threads:[~2026-10-16 8:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 13:49 [PATCH] gpiolib: cdev: don't record a line direction the driver refused Adrian Ambrozewicz
2026-10-12 14:04 ` sashiko-bot
2026-10-14 4:36 ` Kent Gibson
2026-10-15 13:36 ` Bartosz Golaszewski
2026-10-15 15:37 ` Kent Gibson
2026-10-16 7:46 ` Adrian Ambrozewicz
2026-10-16 8:37 ` Kent Gibson [this message]
2026-10-16 8:57 ` Bartosz Golaszewski
2026-10-16 9:19 ` Adrian Ambrozewicz
2026-10-16 8:23 ` Bartosz Golaszewski
2026-10-16 9:14 ` Kent Gibson
2026-10-14 4:56 ` Kent Gibson
2026-10-16 7:46 ` Adrian Ambrozewicz
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=20261016083709.GA56522@rigel \
--to=warthog618@gmail.com \
--cc=aambrozewicz@nvidia.com \
--cc=brgl@kernel.org \
--cc=linux-gpio@vger.kernel.org \
/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.