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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84DCBC6FD18 for ; Tue, 18 Apr 2023 19:57:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231153AbjDRT5L (ORCPT ); Tue, 18 Apr 2023 15:57:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbjDRT5K (ORCPT ); Tue, 18 Apr 2023 15:57:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E85DDB745; Tue, 18 Apr 2023 12:57:06 -0700 (PDT) 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 1D413638A8; Tue, 18 Apr 2023 19:57:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78C26C433EF; Tue, 18 Apr 2023 19:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681847825; bh=NUM/9EfT+oCdQ/ixSz3HeS2pAje1HdCv95koR/4MgXw=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=JXUejncSyNOOCDo8jBZ27fDUD/UKurH9wZTS0gV6Esh2yl9h727mpeTEyIbN6lb9o h24hf90F7jv7CQmfcFVhW+ArrA3OrbDx/Xgfcej1OwEA8yvjJaIlS5JVlCMlkQzyup PooDhkPIfFfASUGlRHWF+JrvvOZ0h2BtFwsvpjz088Ddq5YyvoZRXCSh9J7xiZdouG 8195udD1neDJxPlOrpSh8ql/TijCVTYqHHOiMF70BqgMg3AHIU8dlePTzCaK6XS+LF LILwrO52URPOeZRNix4JL0td0cn+qCXVLg2URtN2EPqPJSw7EDwOBQnnmcVYg7cNg0 sx8dbLU29Dvmg== Message-ID: <86398a778336846688c33a737e2a9ae2.sboyd@kernel.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <5e18370b.3c8a8.1877d7fc98a.Coremail.u201911681@hust.edu.cn> References: <20230413032439.1706448-1-u201911681@hust.edu.cn> <25b06794ffb595229019640e10f256fd.sboyd@kernel.org> <5e18370b.3c8a8.1877d7fc98a.Coremail.u201911681@hust.edu.cn> Subject: Re: Re: [PATCH] clk: imx: clk-imx8mm: fix memory leak issue in 'imx8mm_clocks_probe' From: Stephen Boyd Cc: abel vesa , bai ping , fabio estevam , michael turquette , nxp linux team , peng fan , pengutronix kernel team , sascha hauer , shawn guo , hust-os-kernel-patches@googlegroups.com, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, hao luo To: =?utf-8?b?5ZGo5biI5b63?= Date: Tue, 18 Apr 2023 12:57:03 -0700 User-Agent: alot/0.10 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org Quoting =E5=91=A8=E5=B8=88=E5=BE=B7 (2023-04-13 19:02:19) >=20 >=20 >=20 > > -----=E5=8E=9F=E5=A7=8B=E9=82=AE=E4=BB=B6----- > > =E5=8F=91=E4=BB=B6=E4=BA=BA: "Stephen Boyd" > > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2023-04-14 03:06:59 (=E6=98=9F=E6= =9C=9F=E4=BA=94) > > =E6=94=B6=E4=BB=B6=E4=BA=BA: "Abel Vesa" , "Bai Pi= ng" , "Fabio Estevam" , "Michael Turq= uette" , "NXP Linux Team" , "Pe= ng Fan" , "Pengutronix Kernel Team" , "Sascha Hauer" , "Shawn Guo" , "Zhou Shide" > > =E6=8A=84=E9=80=81: hust-os-kernel-patches@googlegroups.com, "Zhou Shid= e" , linux-clk@vger.kernel.org, linux-arm-kernel@li= sts.infradead.org, linux-kernel@vger.kernel.org, "Hao Luo" > > =E4=B8=BB=E9=A2=98: Re: [PATCH] clk: imx: clk-imx8mm: fix memory leak i= ssue in 'imx8mm_clocks_probe' > >=20 > > 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. > > >=20 > > > 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. > > >=20 > > > 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). > > >=20 > > > 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 test= ed yet. > >=20 > > And you're not coordinating with each other? > What do you mean by "coordinating with each other"? >=20 I see two patches to the same driver from the same university on the list. Preferably you coordinate and decide who will fix what smatch warnings.