[PATCH] serial: sc16is7xx: Fix clock leak on invalid clock frequency

From: laixiangwu

Date: Fri Oct 30 2026 - 04:56:47 EST


sc16is7xx_probe() enables the clock with clk_prepare_enable() early in
the probe path. If the resulting clock frequency cannot be determined
(neither from the clock itself, nor from the "clock-frequency" property
or platform data), the driver bails out with -EINVAL, but it does so
with a plain return, leaving the clock prepared and enabled.

All the later error paths of the probe already jump to the out_clk
label to disable the clock. Do the same here.

Fixes: cb1b206cff46 ("serial: sc16is7xx: Use devm_clk_get_optional()")
Signed-off-by: laixiangwu <laixiangwu@xxxxxxxxxxxxxxxxxxxx>
---
drivers/tty/serial/sc16is7xx.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index fba588559..e464c6d72 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1619,10 +1619,12 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype,
freq = uartclk;
if (pfreq)
freq = *pfreq;
- if (freq)
+ if (freq) {
dev_dbg(dev, "Clock frequency: %luHz\n", freq);
- else
- return -EINVAL;
+ } else {
+ ret = -EINVAL;
+ goto out_clk;
+ }
}

s->devtype = devtype;
--