[PATCH] pinctrl: spear: plgpio: Unprepare the clock on probe failure

Tian Xuechen 202300460064 at mail.sdu.edu.cn
Tue Dec 1 05:22:43 PST 2026


plgpio_probe() prepares the clock before allocating the parent IRQ
array. If the allocation fails, probe returns -ENOMEM without undoing
a successful clk_prepare().

Set ret to -ENOMEM and use the existing unprepare_clk path so that
the clock preparation is balanced and the allocation error is
returned.

Fixes: face7c04b030 ("pinctrl: spear/plgpio: Pass irqchip when adding gpiochip")
Signed-off-by: Tian Xuechen <202300460064 at mail.sdu.edu.cn>
---
An AI coding assistant helped trace the probe error path and draft the
cleanup and commit message.

 drivers/pinctrl/spear/pinctrl-plgpio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/spear/pinctrl-plgpio.c b/drivers/pinctrl/spear/pinctrl-plgpio.c
index b5fc76e..fa33fec 100644
--- a/drivers/pinctrl/spear/pinctrl-plgpio.c
+++ b/drivers/pinctrl/spear/pinctrl-plgpio.c
@@ -602,8 +602,10 @@ static int plgpio_probe(struct platform_device *pdev)
 		girq->parent_handler = plgpio_irq_handler;
 		girq->num_parents = 1;
 		girq->parents = devm_kzalloc_objs(&pdev->dev, *girq->parents, 1);
-		if (!girq->parents)
-			return -ENOMEM;
+		if (!girq->parents) {
+			ret = -ENOMEM;
+			goto unprepare_clk;
+		}
 		girq->parents[0] = irq;
 		girq->default_type = IRQ_TYPE_NONE;
 		girq->handler = handle_simple_irq;

base-commit: 19cc08c1a6a650f8e54c0461ff198be6448f425d



More information about the linux-arm-kernel mailing list