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 9FAB5C77B6E for ; Thu, 13 Apr 2023 19:08:10 +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:Date:To:Cc:From:Subject:References: In-Reply-To:MIME-Version:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mp+k9gOXLEcGJDlD076iVQfii1VX/ntOsKlL0CmxesU=; b=JfPyFEvEQnxyoZ 0yJmwfnTBLjqWNZ689M8tVD6QBLffnpvjI7j2oCWX3VoxTRD4nOP2AstHGv4TxLgvOlGlQqtJiN9y QWVrR/TqlRfMdXaTHpiizxw9Uq09+EzPJC0BgB7G8DQ257/IzZSFjpaDDZ4jsMimLfnQZd2ClEQtR Ecbc1rA0zvf+g3esDWX1uYauZq4tMJirKw/43jJafGqMBUWPda7cc8DnNUFj0MSj/npwOmSIOqiJ4 a0l9u25h5SUFrR1uxiPOBzbtFr4IVIabgFsN8hXnZ55pr2097CMFq23B/HfJnhk/uzgaBubKFLxfT bQW3tRcyHGvI6wklpXLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pn2Hh-006yAj-2Z; Thu, 13 Apr 2023 19:07:05 +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 1pn2He-006yAH-2S for linux-arm-kernel@lists.infradead.org; Thu, 13 Apr 2023 19:07:03 +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 1F3FE60A0C; Thu, 13 Apr 2023 19:07:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CB8CC433D2; Thu, 13 Apr 2023 19:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681412821; bh=oojxmeg84uBgy5mEglQuFVEA6UgalGkZRPBKKPKhBFo=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=A9ga6TkO9EMOZPFaQ75gllB5vx3pE6c4bPHHnSNDa2fzU+civgoKu5AQoFGHHPlxU OBSDwiy82lW4uZq9YTsWeB4jlmVvKxIUVE16FFibdydX2tNTXq51bd52lpA8zhKpYL qFOMFzYi4ObKq+4uxPXpBOvQlCp7d+xlFyOTU15EpgX9Y3b2wqQYA+Q+T76T36XFco t7zjYQXHMcs0D8T9EbJZmKPJr6032MyAinfTe8Kqp3KC1a1J4KbAEgDIEufSRDZvlP 2SMQ0PElL1kTdD0Bn8qz6Sxmg8BAgPzEh4a+vs9/N3H5gX+kKn7IVNR7b65n3XdZjR a2gbnGqdCpJPA== Message-ID: <25b06794ffb595229019640e10f256fd.sboyd@kernel.org> MIME-Version: 1.0 In-Reply-To: <20230413032439.1706448-1-u201911681@hust.edu.cn> References: <20230413032439.1706448-1-u201911681@hust.edu.cn> Subject: Re: [PATCH] clk: imx: clk-imx8mm: fix memory leak issue in 'imx8mm_clocks_probe' From: Stephen Boyd Cc: hust-os-kernel-patches@googlegroups.com, Zhou Shide , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Hao Luo To: Abel Vesa , Bai Ping , Fabio Estevam , Michael Turquette , NXP Linux Team , Peng Fan , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo , Zhou Shide Date: Thu, 13 Apr 2023 12:06:59 -0700 User-Agent: alot/0.10 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230413_120702_841985_E46BCE5E X-CRM114-Status: GOOD ( 13.77 ) 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 Quoting Zhou Shide (2023-04-12 20:24:39) > The function imx8mm_clocks_probe() has two main issues: > - The of_iomap() function may cause a memory leak. > - Memory allocated for 'clk_hw_data' may not be freed properly > in some paths. > > To fix these issues, this commit replaces the use of of_iomap() > with devm_of_iomap() and replaces kzalloc() with devm_kzalloc(). > This ensures that all memory is properly managed and automatically > freed when the device is removed. > > In addition, when devm_of_iomap() allocates memory with an error, > it will first jump to label "unregister_hws" and > then return PTR_ ERR(base). > > Fixes: 9c71f9ea35d7 ("clk: imx: imx8mm: Switch to clk_hw based API") > Fixes: ba5625c3e272 ("clk: imx: Add clock driver support for imx8mm") > Signed-off-by: Zhou Shide > --- > The issue is discovered by static analysis, and the patch is not tested yet. And you're not coordinating with each other? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel