Re: [PATCH] gpio: omap: handle clk_prepare failure in probe
Andreas Kemnade <[email protected]>
| Newsgroups | org.kernel.vger.linux-omap,org.kernel.vger.linux-gpio,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 18 Aug 2026 17:08:54 +0400 Jiawen Liu <[email protected]> wrote: > 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 <[email protected]> > --- > 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; > + } > What about simply using devm_clk_get_prepared() here? That would simplify things a lot, given that AFAIK, prepare is a no-op here anyways. Regards, Andreas