From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2441AC77B7A for ; Sat, 10 Jun 2023 10:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aSYmq/A+lZ1tjN6v3N4PXYjA6r8GK+MY8t2wEJjaYv4=; b=H2WWlKNwdBrjhm V+OTWYs+dqLE5HHK+hOn+QodDGhAvuzPe07+CZCw2miDV9aYRBEbYphHr0yOoPTrQSErO0QAKLEnM paHMjls+/0yIR4jjqtYS6QyG3WwzEsSoakPO5Lx9T8gq5m9e/UTh6FCixq635goirn9i4BITyBFky q+AdhXnExsbR+opXPsvhUimiT1nYYVP+U1JPxRVQA9V+fKYOvqQpcnl7+v3lmRzhLUJH0LVqtEZ+A KhATMRc+vS1Pzx1Bon+nKHNEZ5q+YNJmGO6EAnQhYmjkwBfsRQQy70wA6zbqD+MyrtigtwHEPmLVM VbiZG9SBatiK/VnXz4QA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7wHV-00FvtN-0Z; Sat, 10 Jun 2023 10:57:17 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7wHS-00Fvsf-1d for linux-arm-kernel@lists.infradead.org; Sat, 10 Jun 2023 10:57:15 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D3E6E60A0C; Sat, 10 Jun 2023 10:57:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CB82C433D2; Sat, 10 Jun 2023 10:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686394633; bh=xmXIIUoIPhbHB+5cKM2HQ7wmex/ZG5xI1clFiieoASQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=S9L8wwnKMlDjtPr/d3+a0NmUf0G1FF0bqLgxJwwEtM1Sezj4CAOgbQcRQJnpcNYms AHhL/vBfcA9uW0sbgP9gXiOuJecbMLEcGafR1I79NNA/TNX3jn5InoWG5wwiASpGk/ slV1EL8SwfZHn6mjDTmcgPJ/6sZR6Rr5NtJIa/znFrpkNw/qkI1SCTLbcFTtl/ecU5 JFRnf34vdanndit99oS/lpIjB747vOK2avosQrl2C+s7rhfk4AV8uhr3FUXzaINpPO nvFKg6Pxly1QtGz55pVipjhbki/MaeRwi1tRleZGTDPC3vK31DzkF+lVn5SAaoCtxE hj/fcE6Yg8UQA== Date: Sat, 10 Jun 2023 12:57:10 +0200 From: Andi Shyti To: Krzysztof Kozlowski Cc: Christophe JAILLET , Alim Akhtar , Greg Kroah-Hartman , Jiri Slaby , Thomas Abraham , Kukjin Kim , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org Subject: Re: [PATCH 2/2] tty: serial: samsung_tty: Fix a memory leak in s3c24xx_serial_getclk() when iterating clk Message-ID: <20230610105710.v6w2ibltfgishali@intel.intel> References: <93bf8f574310256fcea50e5c5a62b5c37e20bb14.1686285892.git.christophe.jaillet@wanadoo.fr> <20230610103958.jwfe45zm52ehiovn@intel.intel> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230610_035714_602025_97821DC7 X-CRM114-Status: GOOD ( 27.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Krzysztof, > On Sat, Jun 10, 2023 at 12:45:53PM +0200, Krzysztof Kozlowski wrote: > On 10/06/2023 12:39, Andi Shyti wrote: > > Hi Christophe, > > > > On Fri, Jun 09, 2023 at 06:45:39AM +0200, Christophe JAILLET wrote: > >> When the best clk is searched, we iterate over all possible clk. > >> > >> If we find a better match, the previous one, if any, needs to be freed. > >> If a better match has already been found, we still need to free the new > >> one, otherwise it leaks. > >> > >> Fixes: 5f5a7a5578c5 ("serial: samsung: switch to clkdev based clock lookup") > >> Signed-off-by: Christophe JAILLET > >> --- > >> This patch is speculative. Review with care. > >> > >> I think that some clk_put() are also missing somewhere else in the driver > >> but won't be able to investigate further. > >> --- > >> drivers/tty/serial/samsung_tty.c | 8 ++++++++ > >> 1 file changed, 8 insertions(+) > >> > >> diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c > >> index dd751e7010e3..c07877dd25fa 100644 > >> --- a/drivers/tty/serial/samsung_tty.c > >> +++ b/drivers/tty/serial/samsung_tty.c > >> @@ -1488,10 +1488,18 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, > >> calc_deviation = -calc_deviation; > >> > >> if (calc_deviation < deviation) { > >> + /* > >> + * If we find a better clk, release the previous one, if > >> + * any. > >> + */ > >> + if (!IS_ERR(*best_clk)) > > > > what is the case when *best_clk has an error in it? > > The initial one? Open the place where the function is being called. Right! Reviewed-by: Andi Shyti Andi > > Best regards, > Krzysztof > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel