Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2876518rwl; Thu, 13 Apr 2023 12:07:28 -0700 (PDT) X-Google-Smtp-Source: AKy350b0tqLDKe57TgfcuMK4FRV6W85XPkVnQAk2K1SQTTUFV+mwazolhxTIIXxZqImfLltNmyLb X-Received: by 2002:a17:903:187:b0:1a2:8c7e:f301 with SMTP id z7-20020a170903018700b001a28c7ef301mr24770plg.45.1681412848292; Thu, 13 Apr 2023 12:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681412848; cv=none; d=google.com; s=arc-20160816; b=EuEg1SCmyMaiwwrvLKVHZuM5pTycycew8LtrjtLvQ2fSiTpwpo4GU+CvFJfK4qOH3Z kbVzSTUyAAPvVUZL7TBHmmq+AvHmhDkJuho8XB89TDH09xdkKquu3e6hv0mi1cQoV6Cj 1MzS/d2De+MLlTawxZbRYlcIfa2Kez7mOV8l1m0peIYGARZFLvMZeZ8w9sz5/yaZbSwg c9Bip2d/3ZydjUyb77t0e3T+riDaYZlkGOGNmU4+i4BTwZ9RKt00gP6uOqSp+0HoHclX wSVAQbvdiy3IN+JxZZ7/sYInG1PwE4J8ROG4HNXV2F/MwnswQO73UHQkorDN/J27XN4u CdqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:date:to:cc:from:subject:references :in-reply-to:content-transfer-encoding:mime-version:message-id :dkim-signature; bh=oojxmeg84uBgy5mEglQuFVEA6UgalGkZRPBKKPKhBFo=; b=D2Hbursc5+NpnEKLDS3tiUfFoIjb9iNqnGiIyi1Qhnb1A7/0082nWLxLy3jzB9pXZa 20oAv1Gdn0TPP1I7DNrcyNBhOp548UKs3t+4zma8L2JhZv4ywnGCKR8NOmOmbACY+twR UmQQEfRtGn7jLoXl1RAItAN42ZHDOqPW0XqjreNKm+xuDej1ro3WMdsWhJBvqEfj3YtD BkARY6WacPsEfnmjNpR7u1CejtViTpLfuE83Fw5n3Mo/wYvV6e7EXJiAoUJL0wKHKq8F 2sgdiKmbA+peD81qOVqQ+Of3mHXI/LdklD0XnEIncvtudl4yDDg6Cf17jF0P9iCv4JS4 fqVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A9ga6TkO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jc1-20020a17090325c100b0019ca1961bc1si2570139plb.108.2023.04.13.12.07.13; Thu, 13 Apr 2023 12:07:28 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A9ga6TkO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229854AbjDMTHF (ORCPT + 99 others); Thu, 13 Apr 2023 15:07:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbjDMTHE (ORCPT ); Thu, 13 Apr 2023 15:07:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACDB07AB3; Thu, 13 Apr 2023 12:07:02 -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 3AED060C92; 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> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 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 tested y= et. And you're not coordinating with each other?