mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ethan Tidmore <ethantidmore06@gmail.com>
To: linusw@kernel.org, joshua.henderson@microchip.com
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ethan Tidmore <ethantidmore06@gmail.com>
Subject: [PATCH] pinctrl: pinctrl-pic32: Fix resource leaks
Date: Tue, 24 Feb 2026 14:28:46 -0600	[thread overview]
Message-ID: <20260224202846.2437400-1-ethantidmore06@gmail.com> (raw)

Add three missing clk_disable_unprepare() in early return error paths.

Detected by Smatch:
drivers/pinctrl/pinctrl-pic32.c:2211 pic32_pinctrl_probe() warn:
'pctl->clk' from clk_prepare_enable() not released on lines: 2208.

drivers/pinctrl/pinctrl-pic32.c:2274 pic32_gpio_probe() warn:
'bank->clk' from clk_prepare_enable() not released on lines: 2264,2272.

Fixes: 2ba384e6c3810 ("pinctrl: pinctrl-pic32: Add PIC32 pin control driver")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 drivers/pinctrl/pinctrl-pic32.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-pic32.c b/drivers/pinctrl/pinctrl-pic32.c
index eb438c9d9667..cf098c183b14 100644
--- a/drivers/pinctrl/pinctrl-pic32.c
+++ b/drivers/pinctrl/pinctrl-pic32.c
@@ -2204,6 +2204,7 @@ static int pic32_pinctrl_probe(struct platform_device *pdev)
 	pctl->pctldev = devm_pinctrl_register(&pdev->dev, &pic32_pinctrl_desc,
 					      pctl);
 	if (IS_ERR(pctl->pctldev)) {
+		clk_disable_unprepare(pctl->clk);
 		dev_err(&pdev->dev, "Failed to register pinctrl device\n");
 		return PTR_ERR(pctl->pctldev);
 	}
@@ -2260,8 +2261,10 @@ static int pic32_gpio_probe(struct platform_device *pdev)
 	girq->num_parents = 1;
 	girq->parents = devm_kcalloc(&pdev->dev, 1, sizeof(*girq->parents),
 				     GFP_KERNEL);
-	if (!girq->parents)
-		return -ENOMEM;
+	if (!girq->parents) {
+		ret = -ENOMEM;
+		goto err_clk_cleanup;
+	}
 	girq->default_type = IRQ_TYPE_NONE;
 	girq->handler = handle_level_irq;
 	girq->parents[0] = irq;
@@ -2269,9 +2272,13 @@ static int pic32_gpio_probe(struct platform_device *pdev)
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to add GPIO chip %u: %d\n",
 			id, ret);
-		return ret;
+		goto err_clk_cleanup;
 	}
 	return 0;
+
+err_clk_cleanup:
+	clk_disable_unprepare(bank->clk);
+	return ret;
 }
 
 static const struct of_device_id pic32_pinctrl_of_match[] = {
-- 
2.53.0


             reply	other threads:[~2026-02-24 20:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24 20:28 Ethan Tidmore [this message]
2026-02-26 22:37 ` Linus Walleij
2026-02-27 21:01   ` Ethan Tidmore
2026-02-27 21:12     ` Linus Walleij

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=20260224202846.2437400-1-ethantidmore06@gmail.com \
    --to=ethantidmore06@gmail.com \
    --cc=joshua.henderson@microchip.com \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®