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 8B6A9C7EE29 for ; Sat, 10 Jun 2023 10:40:39 +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=Q8eJuj7kZAGq22NvXn/x+O/j9S1P9LokwATryhhbrE4=; b=NFp4BJI/cZUGgY HwI3j3jv4cikn8ZgZHsfiANawsD5SkqRvkM7mf/aocCyOrl2W+cWjKptiW0C6567AjYxJi60O+ieg 1QM11/rO1iJopySCQ7WPoHYRMHaU/xpaW6Y81P27OXLxOPthJgvCJftxLwNkpeaViJa30sRwj9YNr 1oRR9aiLrRF8X7LKCLjEoxcFVSqAnto1skF3709XDNXtT14gMZBkt9Pf+AjrARsAqq7Iu4V9GFVjj Ubt9AzAEoFmb1kqk4w5Zmd60cb/LKpewdwxOUrMIAEApIxmAuDQQ31GcZEAMs8/0RkwwhhXdbPs1v 8iFTL1q/XK556cHLB0tA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7w0t-00FuHl-2g; Sat, 10 Jun 2023 10:40:07 +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 1q7w0q-00FuHK-2p for linux-arm-kernel@lists.infradead.org; Sat, 10 Jun 2023 10:40:06 +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 E43B3609EB; Sat, 10 Jun 2023 10:40:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D03EEC433D2; Sat, 10 Jun 2023 10:40:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686393602; bh=r8AP7uSarwpq7WnXRU2o6hNIb1YSsBuKkaXUnHKOXCM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XtToDoekY0U7TcT2sl67IYf4iNg7zioYwonvnwVxParKKBjYD+3tVoUX/9ye+Haqw fCJy68rXb+Y3kOEGB11QqOgtfGHBoxk5QkPz/SL9ek7Ns8//zR5qdRBdS6rblhrC1V seZ8rg21oVANEilNrCEaZZm4Yodgy7WNk+RLrfroKJg7y24700zchPVIc2wjji9ZL+ 9MlARA1OK2+PgjlrFm4bTlirXEV/vXkpIgHfYZ9awo7Zg2tpS4UIseBazGlsngxq06 c7aKp2KYrhNzBXkrSE2VHu8j8+xTPfInEs4Nk3zAgkp4fk6iS7zZ2EQXTdrm9Rmhuy 8UFnd67i8oHbA== Date: Sat, 10 Jun 2023 12:39:58 +0200 From: Andi Shyti To: Christophe JAILLET Cc: Krzysztof Kozlowski , 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: <20230610103958.jwfe45zm52ehiovn@intel.intel> References: <93bf8f574310256fcea50e5c5a62b5c37e20bb14.1686285892.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <93bf8f574310256fcea50e5c5a62b5c37e20bb14.1686285892.git.christophe.jaillet@wanadoo.fr> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230610_034004_977338_BFE3EA99 X-CRM114-Status: GOOD ( 25.99 ) 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 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? Andi > + clk_put(*best_clk); > *best_clk = clk; > best_quot = quot; > *clk_num = cnt; > deviation = calc_deviation; > + } else { > + clk_put(clk); > } > } > > -- > 2.34.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel