1 From a9c09546e903f1068acfa38e1ee18bded7114b37 Mon Sep 17 00:00:00 2001
2 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
3 Date: Sat, 10 Jun 2023 17:59:25 +0200
4 Subject: tty: serial: samsung_tty: Fix a memory leak in s3c24xx_serial_getclk() in case of error
6 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
8 commit a9c09546e903f1068acfa38e1ee18bded7114b37 upstream.
10 If clk_get_rate() fails, the clk that has just been allocated needs to be
13 Cc: <stable@vger.kernel.org> # v3.3+
14 Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
15 Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
16 Fixes: 5f5a7a5578c5 ("serial: samsung: switch to clkdev based clock lookup")
17 Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
18 Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
19 Message-ID: <e4baf6039368f52e5a5453982ddcb9a330fc689e.1686412569.git.christophe.jaillet@wanadoo.fr>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 drivers/tty/serial/samsung.c | 6 +++++-
23 1 file changed, 5 insertions(+), 1 deletion(-)
25 --- a/drivers/tty/serial/samsung.c
26 +++ b/drivers/tty/serial/samsung.c
27 @@ -1177,8 +1177,12 @@ static unsigned int s3c24xx_serial_getcl
30 rate = clk_get_rate(clk);
33 + dev_err(ourport->port.dev,
34 + "Failed to get clock rate for %s.\n", clkname);
39 if (ourport->info->has_divslot) {
40 unsigned long div = rate / req_baud;