Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Linus Walleij <linusw@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	Jianqun Xu <jay.xu@rock-chips.com>,
	linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH 04/10] gpio: rockchip: Unregister gpiochip on pin-range lookup errors
Date: Thu,  3 Dec 2026 20:55:02 +0000	[thread overview]
Message-ID: <20261203205606.3905705-5-lee@kernel.org> (raw)
In-Reply-To: <20261203205606.3905705-1-lee@kernel.org>

After gpiochip_add_data() succeeds in rockchip_gpiolib_register(), the
fallback path when gpio-ranges is absent returns -ENODATA or -ENODEV
directly when the parent pinctrl node or device cannot be found,
skipping the fail label that calls gpiochip_remove().

Jump to the fail label on both error paths so the GPIO chip is properly
unregistered on probe failure.

Fixes: 936ee2675eee ("gpio/rockchip: add driver for rockchip gpio")
Closes: https://sashiko.dev/#/bug/linux-d336bb33-7381-45ac-868f-1124190c27a1
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/gpio/gpio-rockchip.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index 714604c11d78..a620c98718de 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -613,13 +613,17 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
 		struct device_node *pctlnp = of_get_parent(bank->of_node);
 		struct pinctrl_dev *pctldev = NULL;
 
-		if (!pctlnp)
-			return -ENODATA;
+		if (!pctlnp) {
+			ret = -ENODATA;
+			goto fail;
+		}
 
 		pctldev = of_pinctrl_get(pctlnp);
 		of_node_put(pctlnp);
-		if (!pctldev)
-			return -ENODEV;
+		if (!pctldev) {
+			ret = -ENODEV;
+			goto fail;
+		}
 
 		ret = gpiochip_add_pin_range(gc, dev_name(pctldev->dev), 0,
 					     bank->pin_base, bank->nr_pins);
-- 
2.56.1.911.g883d8bcb20-goog



      reply	other threads:[~2026-12-03 20:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 20:54 [PATCH 00/10] gpio: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-03 20:55 ` Lee Jones [this message]

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=20261203205606.3905705-5-lee@kernel.org \
    --to=lee@kernel.org \
    --cc=brgl@kernel.org \
    --cc=heiko@sntech.de \
    --cc=jay.xu@rock-chips.com \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox