Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH v8 3/5] gpio: shared: unwind partial failures in gpiochip_setup_shared()
Date: Thu, 29 Oct 2026 16:52:14 +0000	[thread overview]
Message-ID: <sashiko-outbox-189687@kernel.org> (raw)
In-Reply-To: <20261029-gpio-shared-fwnode-lookup-v8-3-d15d75cd560f@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] gpio: mix of scoped_guard() and goto cleanup in gpio_shared_setup_entry()
--

commit 2481d0c90c9615bb803575d8a0c1c3449eb188b0
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

gpio: shared: unwind partial failures in gpiochip_setup_shared()

This patch updates gpio_shared_setup_entry() and gpiochip_setup_shared() to
unwind previously registered auxiliary devices and completed entries when a
partial failure occurs during setup.

> diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c
> index 47b434db72f1e..043d5daba7a73 100644
> --- a/drivers/gpio/gpiolib-shared.c
> +++ b/drivers/gpio/gpiolib-shared.c
> @@ -589,13 +589,25 @@ static int gpio_shared_setup_entry(struct gpio_chip *gc,
>  			 ref->con_id ?: "(none)");
>  
>  		ret = gpio_shared_make_adev(gdev, entry, ref);
> -		if (ret) {
> -			gpiod_free_commit(desc);
> -			return ret;
> -		}
> +		if (ret)
> +			goto err_out;
>  	}
>  
>  	return 0;
> +
> +err_out:
> +	gpiod_free_commit(desc);
> +	list_for_each_entry_continue_reverse(ref, &entry->refs, list)
> +		gpio_shared_remove_adev(&ref->adev);
> +
> +	return ret;
> +}

[Severity: Low]
This isn't a bug since the scoped_guard() block has already exited before the
loop, but include/linux/cleanup.h advises against mixing goto error handling
and scope-based cleanup helpers in the same function:

drivers/gpio/gpiolib-shared.c:gpio_shared_setup_entry() {
	...
	scoped_guard(mutex, &entry->lock) {
		...
	}

	list_for_each_entry(ref, &entry->refs, list) {
		...
		ret = gpio_shared_make_adev(gdev, entry, ref);
		if (ret)
			goto err_out;
	}
}

Since err_out only has a single caller when gpio_shared_make_adev() fails,
could the cleanup be kept inline inside the if (ret) block instead of adding a
goto label?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261029-gpio-shared-fwnode-lookup-v8-0-d15d75cd560f@oss.qualcomm.com?part=3

  reply	other threads:[~2026-10-29 16:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 16:22 [PATCH v8 0/5] gpio: shared: replace platform lookup with dummy software nodes Bartosz Golaszewski
2026-10-29 16:22 ` [PATCH v8 1/5] gpio: shared: factor out per-entry teardown helper Bartosz Golaszewski
2026-10-29 16:22 ` [PATCH v8 2/5] gpio: shared: factor out per-entry setup helper Bartosz Golaszewski
2026-10-29 16:22 ` [PATCH v8 3/5] gpio: shared: unwind partial failures in gpiochip_setup_shared() Bartosz Golaszewski
2026-10-29 16:52   ` sashiko-bot [this message]
2026-10-29 16:22 ` [PATCH v8 4/5] gpio: shared: detach the proxy device from struct gpio_shared_ref Bartosz Golaszewski
2026-10-29 16:22 ` [PATCH v8 5/5] gpio: shared: convert to using software nodes for GPIO shared proxy lookup Bartosz Golaszewski
2026-10-29 17:12   ` sashiko-bot

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-189687@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