Commit 002679f7 authored by Haotian Zhang's avatar Haotian Zhang Committed by Linus Walleij
Browse files

pinctrl: stm32: fix hwspinlock resource leak in probe function



In stm32_pctl_probe(), hwspin_lock_request_specific() is called to
request a hwspinlock, but the acquired lock is not freed on multiple
error paths after this call. This causes resource leakage when the
function fails to initialize properly.

Use devm_hwspin_lock_request_specific() instead of
hwspin_lock_request_specific() to automatically manage the hwspinlock
resource lifecycle.

Fixes: 97cfb6cd ("pinctrl: stm32: protect configuration registers with a hwspinlock")
Signed-off-by: default avatarHaotian Zhang <vulab@iscas.ac.cn>
Reviewed-by: default avatarAntonio Borneo <antonio.borneo@foss.st.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent f9f4fda1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1872,7 +1872,7 @@ int stm32_pctl_probe(struct platform_device *pdev)
		if (hwlock_id == -EPROBE_DEFER)
			return hwlock_id;
	} else {
		pctl->hwlock = hwspin_lock_request_specific(hwlock_id);
		pctl->hwlock = devm_hwspin_lock_request_specific(dev, hwlock_id);
	}

	spin_lock_init(&pctl->irqmux_lock);