* [PATCH] serial: sc16is7xx: Fix clock leak on invalid clock frequency
@ 2026-10-30 8:55 laixiangwu
2026-10-30 8:57 ` sashiko-bot
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: laixiangwu @ 2026-10-30 8:55 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby; +Cc: linux-kernel, linux-serial, laixiangwu
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@cmss.chinamobile.com>
---
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;
--
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] serial: sc16is7xx: Fix clock leak on invalid clock frequency 2026-10-30 8:55 [PATCH] serial: sc16is7xx: Fix clock leak on invalid clock frequency laixiangwu @ 2026-10-30 8:57 ` sashiko-bot 2026-11-11 9:52 ` Xiangwu Lai 2026-11-12 21:39 ` Hugo Villeneuve 2 siblings, 0 replies; 7+ messages in thread From: sashiko-bot @ 2026-10-30 8:57 UTC (permalink / raw) To: laixiangwu; +Cc: linux-serial > 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@cmss.chinamobile.com> Sashiko has reviewed this patch and found no issues. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261030085508.1882-1-laixiangwu@cmss.chinamobile.com?part=1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] serial: sc16is7xx: Fix clock leak on invalid clock frequency 2026-10-30 8:55 [PATCH] serial: sc16is7xx: Fix clock leak on invalid clock frequency laixiangwu 2026-10-30 8:57 ` sashiko-bot @ 2026-11-11 9:52 ` Xiangwu Lai 2026-11-11 13:16 ` Greg Kroah-Hartman 2026-11-12 21:39 ` Hugo Villeneuve 2 siblings, 1 reply; 7+ messages in thread From: Xiangwu Lai @ 2026-11-11 9:52 UTC (permalink / raw) To: Greg Kroah-Hartman, Jiri Slaby; +Cc: Xiangwu Lai, linux-serial, linux-kernel Hi, gentle ping. Is there anything blocking this patch, or does it just need more time? Best regards, Xiangwu Lai ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] serial: sc16is7xx: Fix clock leak on invalid clock frequency 2026-11-11 9:52 ` Xiangwu Lai @ 2026-11-11 13:16 ` Greg Kroah-Hartman 2026-11-12 2:13 ` Xiangwu Lai 0 siblings, 1 reply; 7+ messages in thread From: Greg Kroah-Hartman @ 2026-11-11 13:16 UTC (permalink / raw) To: Xiangwu Lai; +Cc: Jiri Slaby, linux-serial, linux-kernel On Wed, Nov 11, 2026 at 05:52:12PM +0800, Xiangwu Lai wrote: > Hi, > > gentle ping. Is there anything blocking this patch, or does it just > need more time? There is no context here :( ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] serial: sc16is7xx: Fix clock leak on invalid clock frequency 2026-11-11 13:16 ` Greg Kroah-Hartman @ 2026-11-12 2:13 ` Xiangwu Lai 2026-11-12 21:33 ` Hugo Villeneuve 0 siblings, 1 reply; 7+ messages in thread From: Xiangwu Lai @ 2026-11-12 2:13 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: Xiangwu Lai, Jiri Slaby, linux-serial, linux-kernel Hi Greg, sorry for the missing context. The patch I was pinging is: serial: sc16is7xx: Fix clock leak on invalid clock frequency https://lore.kernel.org/all/20261030085508.1882-1-laixiangwu@cmss.chinamobile.com/ sc16is7xx_probe() enables the clock with clk_prepare_enable() early in the probe path. If the 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 without disabling the clock again, while the later error paths of the probe already jump to the out_clk label. The patch makes this error path jump to out_clk as well, so the clock is disabled like on the other error paths. It was submitted on Oct 30. Is there anything blocking it, or does it just need more time? Best regards, Xiangwu Lai ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] serial: sc16is7xx: Fix clock leak on invalid clock frequency 2026-11-12 2:13 ` Xiangwu Lai @ 2026-11-12 21:33 ` Hugo Villeneuve 0 siblings, 0 replies; 7+ messages in thread From: Hugo Villeneuve @ 2026-11-12 21:33 UTC (permalink / raw) To: Xiangwu Lai; +Cc: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel Hi, On Thu, 12 Nov 2026 10:13:34 +0800 Xiangwu Lai <laixiangwu@cmss.chinamobile.com> wrote: > Hi Greg, > > sorry for the missing context. The patch I was pinging is: > > serial: sc16is7xx: Fix clock leak on invalid clock frequency > https://lore.kernel.org/all/20261030085508.1882-1-laixiangwu@cmss.chinamobile.com/ > > sc16is7xx_probe() enables the clock with clk_prepare_enable() early > in the probe path. If the 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 > without disabling the clock again, while the later error paths of > the probe already jump to the out_clk label. The patch makes this > error path jump to out_clk as well, so the clock is disabled like > on the other error paths. It is better to simply reply to the original email, to have the full context, without having to click on a link to see the original message. > > It was submitted on Oct 30. Is there anything blocking it, or does > it just need more time? I'll reply in the original email... -- Hugo Villeneuve ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] serial: sc16is7xx: Fix clock leak on invalid clock frequency 2026-10-30 8:55 [PATCH] serial: sc16is7xx: Fix clock leak on invalid clock frequency laixiangwu 2026-10-30 8:57 ` sashiko-bot 2026-11-11 9:52 ` Xiangwu Lai @ 2026-11-12 21:39 ` Hugo Villeneuve 2 siblings, 0 replies; 7+ messages in thread From: Hugo Villeneuve @ 2026-11-12 21:39 UTC (permalink / raw) To: laixiangwu; +Cc: Greg Kroah-Hartman, Jiri Slaby, linux-kernel, linux-serial Hi, On Fri, 30 Oct 2026 16:55:07 +0800 laixiangwu <laixiangwu@cmss.chinamobile.com> wrote: > 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@cmss.chinamobile.com> > --- > 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; > -- You can probably switch to using devm_clk_get_optional_enabled(), to simplify and completely get rid of the goto and out_clk label? Something along: - s->clk = devm_clk_get_optional(dev, NULL); + s->clk = devm_clk_get_optional_enabled(dev, NULL); if (IS_ERR(s->clk)) return PTR_ERR(s->clk); - ret = clk_prepare_enable(s->clk); - if (ret) - return ret; - freq = clk_get_rate(s->clk); if (freq == 0) { if (uartclk) @@ -1631,10 +1627,8 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype, kthread_init_worker(&s->kworker); s->kworker_task = kthread_run(kthread_worker_fn, &s->kworker, "sc16is7xx"); - if (IS_ERR(s->kworker_task)) { - ret = PTR_ERR(s->kworker_task); - goto out_clk; - } + if (IS_ERR(s->kworker_task)) + return PTR_ERR(s->kworker_task); + sched_set_fifo(s->kworker_task); ret = sc16is7xx_reset(dev, regmaps[0]); @@ -1711,9 +1705,6 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype, out_kthread: kthread_stop(s->kworker_task); -out_clk: - clk_disable_unprepare(s->clk); - return ret; } EXPORT_SYMBOL_GPL(sc16is7xx_probe); @@ -1740,8 +1731,6 @@ void sc16is7xx_remove(struct device *dev) kthread_flush_worker(&s->kworker); kthread_stop(s->kworker_task); - - clk_disable_unprepare(s->clk); } EXPORT_SYMBOL_GPL(sc16is7xx_remove); -- Hugo Villeneuve ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-12 21:39 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-10-30 8:55 [PATCH] serial: sc16is7xx: Fix clock leak on invalid clock frequency laixiangwu 2026-10-30 8:57 ` sashiko-bot 2026-11-11 9:52 ` Xiangwu Lai 2026-11-11 13:16 ` Greg Kroah-Hartman 2026-11-12 2:13 ` Xiangwu Lai 2026-11-12 21:33 ` Hugo Villeneuve 2026-11-12 21:39 ` Hugo Villeneuve
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.