Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1754514rwr; Fri, 28 Apr 2023 01:03:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4qkIcgC3PD5zJBrJY5xUv3FINQrgM38204fYTCkFthuFCbkWUet64maP79Yvh5Wt8ePNnB X-Received: by 2002:a05:6a20:a10d:b0:f0:d50c:4ac5 with SMTP id q13-20020a056a20a10d00b000f0d50c4ac5mr5459219pzk.51.1682669029332; Fri, 28 Apr 2023 01:03:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1682669029; cv=pass; d=google.com; s=arc-20160816; b=XOSEBiiGiclSa2PkbdvyNyegQWYVlbOM85qjWlw1PRvR7St9wrGDDTlt3eMdah7CBI Ze2oEW0rrVtZ58OJLTLwJtmON92MnYTNU6DDzH/w0Yw5aGOdtwYNSpWCHVHmNwvtM22u DN0Uap+9IsabcOJXPIv4G9UeSeMotEXq+tlAeGpc5bC0Ui9gqIormdCxHUzmpVuNQRuy CyENwJpVhOKsQmyiXzYvzRuGEn50ikvHeibb9EayEfgKFrt6sieEn4qtnM9ZYrNo0yat RiUbN2Pna21zW4p0JPmaeo3Uv461SJU998S3deZ7MLxDRNU0k9+ov+a+uFjQTi9egzOw FjMg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:subject:user-agent:date :message-id:dkim-signature; bh=eFng4f0TiIZd9OV92ZDSNGtY3pehtUAkX9U8HaB5V2Y=; b=PLnVjSrKWmky0UDH4ZeMuiI/BYYmBr27MRXOj5QiFoLo5QtccZA0Mr6C2CjPGnLObd uTH9LjZ+Fy5BzGkvmg1IDxhCNYH6NJtgL+cqw1iBf1P+kRun+hGSXHTDEkS8VgZyAEEH IArL1JqU/u8y9Gmywde1FuMEgk4njUhmfoQ6Jwl+fyE6nbYL9FXqvcn2Pux/QGqqZZHN s9dJINg9ELGwPGaim18tvzAXcU8ZMwiQ7wHRI1O430bbba5vgak8XGcJF6gXe8vT3Een WR1pEpVFr4EvTiDgXdSqMmimixAOM6IQSn8Cb385s7dT8VKSYBy7Fut+QsPxJ5Yivu9t GWlA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=Qsya749X; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a63d442000000b004fc257265cfsi19630010pgj.267.2023.04.28.01.03.36; Fri, 28 Apr 2023 01:03:49 -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=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=Qsya749X; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345612AbjD1HwK (ORCPT + 99 others); Fri, 28 Apr 2023 03:52:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345665AbjD1Hv6 (ORCPT ); Fri, 28 Apr 2023 03:51:58 -0400 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2078.outbound.protection.outlook.com [40.107.241.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB8455275; Fri, 28 Apr 2023 00:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j0y8fOrjh45ZuI7/J1Mc1uNmyXxH1xLfd153EpWcEAPt804rmskaiVG8zeLq84ntdIQJOnh4yIeYisHOud0ZbBZWUwfrF1KKBp12ESRHEKwMSLFCZJaMQJ0SAkyporskcdLUfXNWM9CuKFwLGxHTU00L0i2BjUSQ8wl4+HfdGQfhyKRdZ7Voa9YcVuYNZOQYGHQvGJGgHdLeAankjpTjQZYuY+al+zMYdJoN4HBArV6mrsQVIc3rjqQJ+mAKCvuiFCDFt5zu6HYP41iJ9IxtvPCOiC0HUfiSMVa4KJsrw26QHskVivSQpFGiMF8eQkYXWovsxJL7DaSDgSFsA6vlBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eFng4f0TiIZd9OV92ZDSNGtY3pehtUAkX9U8HaB5V2Y=; b=fgx6R4U+XADD2BqR1yYFei24ID54F70IK0eNbzqd7UaLKA4daL6j3OKpiG1AXKYvvYbjQZWCzyzWNpuygFpZIFCy1kG54K+YTyYK5hYhffKMenNBomRInTYigu2MDSbnIIjjZPpDvn2DHBjYyf8OvtYvcx6IXprWjFieu/PB42rxqfqS1R6GZI1+l7WcEEq1OACu5buQ7us5VLxOJqejocOqIA92PBCLL+TpCMvrjGhsSmljNK/pamt9DTlIS8WQy5yIiIiAH5ROWAHCOyQx+QS9HrGSBM7gVHRN4O/UMqGrOOzZ5/5Ko8o0CMgFt7x0nKD1+6P4xdaq2ptCRTI4zA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eFng4f0TiIZd9OV92ZDSNGtY3pehtUAkX9U8HaB5V2Y=; b=Qsya749XTMiF45Jz2d6VHePRIItvUlmPdLTv0G4dYwgeV3f8FsgPNg/g82RKQWsfsTYTD4YTrlNtyZ6CG5D08xakQtX2sX3oCU69eJb+TMvO3T/Mc8FeOUJ3EzcDKy8jFCX1a1iokJTN4royAyyJLnZXORcviSu6ziJSevHqnM4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PA4PR04MB7728.eurprd04.prod.outlook.com (2603:10a6:102:e8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21; Fri, 28 Apr 2023 07:50:29 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::b999:f2c6:a8cc:7b4]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::b999:f2c6:a8cc:7b4%5]) with mapi id 15.20.6340.022; Fri, 28 Apr 2023 07:50:29 +0000 Message-ID: Date: Fri, 28 Apr 2023 15:50:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; 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: Zhou Shide , Abel Vesa , Peng Fan , Michael Turquette , Stephen Boyd , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Bai Ping Cc: hust-os-kernel-patches@googlegroups.com, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20230413032439.1706448-1-u201911681@hust.edu.cn> From: Peng Fan In-Reply-To: <20230413032439.1706448-1-u201911681@hust.edu.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SI2PR02CA0017.apcprd02.prod.outlook.com (2603:1096:4:194::17) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|PA4PR04MB7728:EE_ X-MS-Office365-Filtering-Correlation-Id: d2988b0e-cceb-4853-cd0f-08db47bd3c0d X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qI33Bk3JesqUj07kNRHsP91A8fDsjnaVjNVSAjxPYU8qExOonVnqQZiYg+TPVXea9eagkNxfEjj324KYH+TTTIplTCWTggP03kt9aeBiunYDhyxKvSWOwX6r8GqpEnhLgxBgfTEcRU3STYtYBDc37xbRWoxfSozVE14mQSsBPwQNyPOAW7M9C6384R5Mf+hvQwl0EFxS4VSvn61nOcXkOg8MRrkNCt+/ohzPMoySo5UvOFsWPnweiqyxSogi36lvxLvg303Zhey8CSFlRxFAafDFsvny2eQAq6fFjDsM1UaL11f/Lp8AVV5p14gmlvyHkrpKVff1dbF1xvkbMdVt20oW7IT5w//io0J8a51BJtLSCkehlFpTST56hb3sNaFWYzhqSKLTbwNsC+e4G3FW644Tuoso15wbs8mmMWn8Tlm0ct05TAY2RrUS908+7zaQ7zj7pKcKQKF2x2ED1Dmuh6pwt8C8ZH0dUaLLwp2bK5hdSRG/8Ds7XuPx2AMS82D5qHCdJwzetxPJzeBz93pY/IiCy3eQMdP6SuSNhEvSC024wD2nKRKJtFhDeyPgs3cGxj7gFic+4NSE0RA9Pe1y6dXFchrGmlEQWKJNYA5ryS7KfWBs3SRTSxzEgYs8Haie0mvvIaJtIDoWoWuKsQJ8m/Wzmae9HV/CRauNEU32PaU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(396003)(376002)(346002)(136003)(39860400002)(451199021)(26005)(6506007)(186003)(6512007)(8676002)(53546011)(6666004)(6486002)(8936002)(110136005)(7416002)(4744005)(316002)(4326008)(86362001)(44832011)(66476007)(921005)(5660300002)(38100700002)(66556008)(66946007)(83380400001)(2906002)(2616005)(478600001)(31686004)(31696002)(41300700001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Nk1BTjhoek1CK0FvMTFwK2haai9Idjg3Q1JxRTNFREx2ZFpGSElOYVUzbDhv?= =?utf-8?B?UmNJL1ZrUVRHeXFoeWxWQzRtL3ZZTVlwTnNKbG9PM0M0a0FOYkY5b1BvalR3?= =?utf-8?B?dVcrOFBLODlvUThLYWFSMEhGa3ZRQjhsMjBIRzlPbzJRWTltRzBFUG5Ja0h4?= =?utf-8?B?b1lGcWJ2TGRjV0tYY0VNYlZHTFY2ZXQrc01uMnNwYzFRL1dWeG40ZmVBaFlk?= =?utf-8?B?WEZwZzZtY2RrQmlEV0J2NmlYZlE0cUhhTTNGbDdJUURMS3FUZklRNlpWeHNO?= =?utf-8?B?U2VrTmZ0dGV3YXNkcDN5WjZGQ3NHQm93QnpySUFsbnhKVHR0MHpoZlk2Z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Nwc?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2988b0e-cceb-4853-cd0f-08db47bd3c0d X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2023 07:50:28.8993 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: q+ePjCdhtzZYBodPWilT5q7pxWuqMxyuKb7cxF8EOr7XsC84FQJiO5t2ynQYJmJAybbevX8E8lgqOxg9juQpyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7728 X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 4/13/2023 11:24 AM, Zhou Shide wrote: > 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 Reviewed-by: Peng Fan