Message ID | 20221107062120.20321-1-xiujianfeng@huawei.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | tty: serial: samsung_tty: Fix clk resource leak issue | expand |
On Mon, Nov 07, 2022 at 02:21:20PM +0800, Xiu Jianfeng wrote: > In the s3c24xx_serial_get_options(), calling clk_get() without clk_put() > will cause clk resource leak issue, this patch fixes it. > > Fixes: b497549a035c ("[ARM] S3C24XX: Split serial driver into core and per-cpu drivers") > Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> > --- > drivers/tty/serial/samsung_tty.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c > index 77d1363029f5..8a3bb9832172 100644 > --- a/drivers/tty/serial/samsung_tty.c > +++ b/drivers/tty/serial/samsung_tty.c > @@ -2529,9 +2529,10 @@ s3c24xx_serial_get_options(struct uart_port *port, int *baud, > sprintf(clk_name, "clk_uart_baud%d", clk_sel); > > clk = clk_get(port->dev, clk_name); > - if (!IS_ERR(clk)) > + if (!IS_ERR(clk)) { > rate = clk_get_rate(clk); > - else > + clk_put(clk); > + } else How was this tested? thanks, greg k-h
On 07/11/2022 08:17, Greg KH wrote: > On Mon, Nov 07, 2022 at 02:21:20PM +0800, Xiu Jianfeng wrote: >> In the s3c24xx_serial_get_options(), calling clk_get() without clk_put() >> will cause clk resource leak issue, this patch fixes it. >> >> Fixes: b497549a035c ("[ARM] S3C24XX: Split serial driver into core and per-cpu drivers") >> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> >> --- >> drivers/tty/serial/samsung_tty.c | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c >> index 77d1363029f5..8a3bb9832172 100644 >> --- a/drivers/tty/serial/samsung_tty.c >> +++ b/drivers/tty/serial/samsung_tty.c >> @@ -2529,9 +2529,10 @@ s3c24xx_serial_get_options(struct uart_port *port, int *baud, >> sprintf(clk_name, "clk_uart_baud%d", clk_sel); >> >> clk = clk_get(port->dev, clk_name); >> - if (!IS_ERR(clk)) >> + if (!IS_ERR(clk)) { >> rate = clk_get_rate(clk); >> - else >> + clk_put(clk); >> + } else > > How was this tested? The driver has such potential missing clk_put in few other places as well: here on success path and few error paths after calling s3c24xx_serial_enable_baudclk(). Yet I am concerned that none of these paths were actually tested... Best regards, Krzysztof
diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index 77d1363029f5..8a3bb9832172 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -2529,9 +2529,10 @@ s3c24xx_serial_get_options(struct uart_port *port, int *baud, sprintf(clk_name, "clk_uart_baud%d", clk_sel); clk = clk_get(port->dev, clk_name); - if (!IS_ERR(clk)) + if (!IS_ERR(clk)) { rate = clk_get_rate(clk); - else + clk_put(clk); + } else rate = 1; *baud = rate / (16 * (ubrdiv + 1));
In the s3c24xx_serial_get_options(), calling clk_get() without clk_put() will cause clk resource leak issue, this patch fixes it. Fixes: b497549a035c ("[ARM] S3C24XX: Split serial driver into core and per-cpu drivers") Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> --- drivers/tty/serial/samsung_tty.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)