The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] gpio: omap: handle clk_prepare failure in probe
@ 2026-08-18 13:08 Jiawen Liu
  2026-08-20  9:19 ` Markus Elfring
  2026-08-20 12:25 ` [PATCH] " Andreas Kemnade
  0 siblings, 2 replies; 6+ messages in thread
From: Jiawen Liu @ 2026-08-18 13:08 UTC (permalink / raw)
  To: Grygorii Strashko, Santosh Shilimkar, Kevin Hilman, Linus Walleij,
	Bartosz Golaszewski, linux-omap, linux-gpio, linux-kernel

omap_gpio_probe() ignores the return value of clk_prepare(bank->dbck).
If clk_prepare fails, the clock is not prepared, but bank->dbck_flag
remains true. Later, omap_gpio_remove() or the probe error path calls
clk_unprepare(bank->dbck) unconditionally when dbck_flag is true,
leading to an unbalanced clock operation.

Check the return value of clk_prepare in omap_gpio_probe. On failure,
clear dbck_flag and return the error, preventing unbalanced
clk_unprepare in remove or error paths.

Signed-off-by: jiawen <1298662399@qq.com>
---
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1462,7 +1462,12 @@
 				"Could not get gpio dbck. Disable debounce\n");
 			bank->dbck_flag = false;
 		} else {
-			clk_prepare(bank->dbck);
+			ret = clk_prepare(bank->dbck);
+			if (ret) {
+				dev_err(dev, "Could not prepare gpio dbck\n");
+				bank->dbck_flag = false;
+				return ret;
+			}
 		}
 	}
 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-20 13:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18 13:08 [PATCH] gpio: omap: handle clk_prepare failure in probe Jiawen Liu
2026-08-20  9:19 ` Markus Elfring
2026-08-20  9:48   ` Andreas Kemnade
2026-08-20 10:47     ` Markus Elfring
2026-08-20 13:43       ` Andreas Kemnade
2026-08-20 12:25 ` [PATCH] " Andreas Kemnade

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox