From patchwork Sat Jun 10 15:59:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 691905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E390BC7EE2F for ; Sat, 10 Jun 2023 15:59:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235624AbjFJP7k (ORCPT ); Sat, 10 Jun 2023 11:59:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231775AbjFJP7j (ORCPT ); Sat, 10 Jun 2023 11:59:39 -0400 Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5351B9B for ; Sat, 10 Jun 2023 08:59:35 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 80zwqFULNV4eY80zwqBQ53; Sat, 10 Jun 2023 17:59:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1686412773; bh=eYz8VPeFQqWxDk20aGLkAdXUCS+n+oiCg0u8zmpFgg4=; h=From:To:Cc:Subject:Date; b=E8Qj0/JL7wXord7afU38rc3n79/MyJkTu9RoEy31bYmwu28ifvGXbl5BpuaZT3Hm0 ZMu2c2rh3BL9b0I7vv//Wxp/IycEhvrXU3HngRiLoVYhfdRS4UVqqggKwIuRjECb5M qExQpuOlxDeBnqha/k40ziJRbOn48aiXSx7qVz2fbXtvyyoexduy+oNBO0ul4uohHk GjAmEjtarIYSttr0kx2ITF2IR0sD8m6dSLaRYOfnLG8QsnVTIvb9dr/HQlBc7jUk76 vQEsrGwPow6A664QSjFgWUM5neBLeI39ZPl8k4qd4Z5cg1XuHQL5wRewPvRtwYw0Vd 8+NFaD1kuUBjA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 10 Jun 2023 17:59:31 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Krzysztof Kozlowski , Alim Akhtar , Greg Kroah-Hartman , Jiri Slaby , Thomas Abraham , Kukjin Kim Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , stable@vger.kernel.org, Andi Shyti , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH v2 1/3] tty: serial: samsung_tty: Fix a memory leak in s3c24xx_serial_getclk() in case of error Date: Sat, 10 Jun 2023 17:59:25 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org If clk_get_rate() fails, the clk that has just been allocated needs to be freed. Cc: # v3.3+ Reviewed-by: Krzysztof Kozlowski Reviewed-by: Andi Shyti Fixes: 5f5a7a5578c5 ("serial: samsung: switch to clkdev based clock lookup") Signed-off-by: Christophe JAILLET Reviewed-by: Jiri Slaby --- v2: Add an error message [Andi Shyti] Add Cc: stable [Andi Shyti] Add R-b tags v1: https://lore.kernel.org/all/e4359d5ef206f5b349c1d15a515a1205e78dda55.1686285892.git.christophe.jaillet@wanadoo.fr/ Slightly unsure if Krzysztof's R-b should be kept or not. v2 is not the same as v1, but the change looks small. Sorry if I did wrong. --- drivers/tty/serial/samsung_tty.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index 2a7520ad3abd..a92a23e1964e 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -1459,8 +1459,12 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, continue; rate = clk_get_rate(clk); - if (!rate) + if (!rate) { + dev_err(ourport->port.dev, + "Failed to get clock rate for %s.\n", clkname); + clk_put(clk); continue; + } if (ourport->info->has_divslot) { unsigned long div = rate / req_baud;