From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH v3 1/4] gpio: kunit: fix the label of the dummy GPIO chip
Date: Tue, 13 Oct 2026 13:14:30 +0000 [thread overview]
Message-ID: <sashiko-outbox-169786@kernel.org> (raw)
In-Reply-To: <20261013-gpio-kunit-plat-lookup-v3-1-3907f913e964@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] gpio: resource leak of gdev on KUnit test assertion failure
--
commit b7e40967a53cb1589f5bac90dea8c80d8d27bce0
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
gpio: kunit: fix the label of the dummy GPIO chip
The label of the test GPIO provider is currently set to the consumer
name. Use the provider name instead.
> diff --git a/drivers/gpio/gpiolib-kunit.c b/drivers/gpio/gpiolib-kunit.c
> --- a/drivers/gpio/gpiolib-kunit.c
> +++ b/drivers/gpio/gpiolib-kunit.c
[ ... ]
> @@ -780,7 +779,7 @@ static void gpio_hog_assert(struct kunit *test, unsigned int offset,
>
> /* The hog must have configured the line with the expected direction. */
> struct gpio_device *gdev __free(gpio_device_put) =
> - gpio_device_find_by_label(GPIO_CONSUMER_NAME);
> + gpio_device_find_by_label(GPIO_TEST_PROVIDER);
> KUNIT_ASSERT_NOT_ERR_OR_NULL(test, gdev);
>
> desc = gpio_device_get_desc(gdev, offset);
> KUNIT_ASSERT_NOT_ERR_OR_NULL(test, desc);
>
> ret = gpiod_get_direction(desc);
> KUNIT_ASSERT_EQ(test, ret, expected_direction);
[Severity: Medium]
Does this code leak the gdev reference when KUnit assertions fail?
If KUNIT_ASSERT_NOT_ERR_OR_NULL(test, desc) or the subsequent KUNIT_ASSERT_EQ()
fails in gpio_hog_assert(), KUnit aborts the test thread immediately using
kthread_exit().
Because kthread_exit() bypasses normal C scope exit, compiler-generated
cleanup handlers like __free(gpio_device_put) are skipped, causing a reference
count leak of the gpio_device.
This leaked reference could prevent the dummy device from being properly freed,
which might wedge subsequent test runs or module unloads.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261013-gpio-kunit-plat-lookup-v3-0-3907f913e964@oss.qualcomm.com?part=1
next prev parent reply other threads:[~2026-10-13 13:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 13:02 [PATCH v3 0/4] gpio: kunit: add test cases for platform lookup tables Bartosz Golaszewski
2026-10-13 13:03 ` [PATCH v3 1/4] gpio: kunit: fix the label of the dummy GPIO chip Bartosz Golaszewski
2026-10-13 13:14 ` sashiko-bot [this message]
2026-10-13 13:03 ` [PATCH v3 2/4] gpio: kunit: factor out common code for waiting for device probe Bartosz Golaszewski
2026-10-13 13:03 ` [PATCH v3 3/4] gpio: kunit: rename the swnode consumer to a more generic test consumer Bartosz Golaszewski
2026-10-13 13:03 ` [PATCH v3 4/4] gpio: kunit: add a test case for platform lookup tables Bartosz Golaszewski
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-169786@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox