Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp1308234rwe; Fri, 14 Apr 2023 19:01:44 -0700 (PDT) X-Google-Smtp-Source: AKy350aT2b5zvYcvcfV54poQni+cbyQEE7Kue4IWXhgk+vG0o/8YZ7833QEIHvmllSzNV1OXhiKJ X-Received: by 2002:a05:6a00:850:b0:626:1523:b10d with SMTP id q16-20020a056a00085000b006261523b10dmr13777335pfk.4.1681524103979; Fri, 14 Apr 2023 19:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681524103; cv=none; d=google.com; s=arc-20160816; b=FwkrHaCqVVEME7m8nc98HzfTAtWdSkpeL2PVDJtUDOM+orndF8l+OlC7lOZHcvrfVT WQH6wOuTQHZ6sEv3iCx/cBw6f8ScAE9hXXPLD0G7I0K5HWCQ0gTfsA+SFlucNaEEFgG+ 9JMrX1gegF51HLQrIoiJWbzATyqDTI73syR0aRmLKV1p9rlZz8Dhd+sf7BfpJTs1cYTX U87Sg+LN9M8N9WCkZzB5y5GTOCfh9GrEGWJKSImBJ7ieUhmRIacwE9JETBAhI3Kr9OMN gGCl2AqfnL/nzCIrXKET514jrYsG0Z0OWO5UEEUJoOEcQAzoGkIab/yAfAVkxxQ5x8OI mkBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=O4E7Vh6/goVsCpRIvF2i9PD6ZykwR+g4BHcrgOaueQo=; b=lv/9b6jmq1j3tpAKuiR2Vp+aV1IJ0u/8VG2Y5v4uNEiIOpvONGGML57MdUZblGNJc5 VREvKhJhu2jKK1+Zy5y37rbazUEESn4lIMCcaM1BQX5N28vXG7/Ibo7gns70cZh7jCTS IvRZQemyvQ61NIryl8CMpnr0sNzFmssEeIwEP06S+BWdrHyd6O5j6kbt9mNY76yvz8X4 xsInYJmGK3diHXmeB2zu8PXwICJXIxFo+cnBIwUVQQAx81rezHv/hbWSH+aL1Z2xaRlQ WYncW6YQlBbm0oUQmzlSjvezsEJLlc6ED8WometwATLSUIhci/7TPox1Xje6GhC5i8Jh cbRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i30-20020a63585e000000b00513128cd495si6085764pgm.730.2023.04.14.19.01.28; Fri, 14 Apr 2023 19:01:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229733AbjDOB5T (ORCPT + 99 others); Fri, 14 Apr 2023 21:57:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjDOB5S (ORCPT ); Fri, 14 Apr 2023 21:57:18 -0400 Received: from hust.edu.cn (mail.hust.edu.cn [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E3B64692; Fri, 14 Apr 2023 18:57:15 -0700 (PDT) Received: from [IPV6:2408:824e:f23:41b0:7819:c897:bdb2:2a7c] ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=PLAIN bits=0) by mx1.hust.edu.cn with ESMTP id 33F1tl6O019421-33F1tl6P019421 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Sat, 15 Apr 2023 09:55:48 +0800 Message-ID: <470c192a-8170-6ea9-eb14-aa678555a789@hust.edu.cn> Date: Sat, 15 Apr 2023 09:55:47 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH] clk: imx: clk-imx8mm: fix memory leak issue in 'imx8mm_clocks_probe' To: Dan Carpenter , Stephen Boyd Cc: Abel Vesa , Bai Ping , Fabio Estevam , Michael Turquette , NXP Linux Team , Peng Fan , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo , Zhou Shide , hust-os-kernel-patches@googlegroups.com, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Hao Luo References: <20230413032439.1706448-1-u201911681@hust.edu.cn> <25b06794ffb595229019640e10f256fd.sboyd@kernel.org> From: Dongliang Mu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-FEAS-AUTH-USER: dzm91@hust.edu.cn X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/4/15 00:38, Dan Carpenter wrote: > On Thu, Apr 13, 2023 at 12:06:59PM -0700, Stephen Boyd wrote: >> 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? >> > This is a university program. The patches are reviewed by his professor > and teaching assistants etc. I've been reviewing some of these patches > as well because of they're using Smatch. Thanks for your explanation, Dan. We are from Huazhong University of Science and Technology. Some undergraduate and graduatestudents who are interested in Linux Kernel are guided by me [1] and Dan to contribute into our kernel community. We found Smatch is really great in finding kernel issues and these issues are suitable for undergraduate students. Therefore, I contacted Dan to do a favor for patch interview. And our internal review are publicly hosted in a google group [2]. Please let me know if you have any questions. [1] https://mudongliang.github.io/about/ [2] https://groups.google.com/g/hust-os-kernel-patches > > regards, > dan carpenter >