Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp327667lfv; Wed, 13 Apr 2022 04:55:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW64Xkm/womAYFDTL0Uk0GOPZRwjzzFjVpBzFTX9qBCEGH8VpVVhOoUgF0h3wqZjUXBUmx X-Received: by 2002:a05:6402:1941:b0:413:2b7e:676e with SMTP id f1-20020a056402194100b004132b7e676emr44060374edz.114.1649850905864; Wed, 13 Apr 2022 04:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649850905; cv=none; d=google.com; s=arc-20160816; b=PS56djeHDxBSq0aISDg1aWYm+op8MEjgjnKvYFYa6qgXUl60tJIBS2MbQjG24YRaoF JFf8PTHqJcbIMWdujMsuEeSlWx/I3wfFeVzQTdIrhC+GZ0BIfrchMBzPn3oJZRBfiwyy LiSMGmg0/rQ5OZY6BNLUPaFzVdWO3V+4eMQNNLZPJuSENx/50IaD+VDgn5iCftOTgX1c KUDyTybcv48GqMtPs89SKxCWcdzJCK57kbirXTeHHCeRrkUi8evcyrRpegN2gSQwHWkC YW5kJkcismUFZNc6SplERO+LUdVSlhp6379vxs8MMyPfV2CcH1AP1JcBNjlHPt74ta4D xuKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=MhynP1bvtaJ+rzkKqjrfrUGdOTlFF+MXRahXQh2Ar0I=; b=o/mw3DMyGwbZSC0YDtGl8SG0ZpMl2mBocfPiNo94tstF9UcipZ0qikZBn0mHyHbGBW fFSsL8fSmmbKVtmbmWf3GBog32rNjgLEIG6We8JmhnNs9TNwyjjGFREF2ajMElTNrjcA hGIeu+kPmuknhIQGXRdiN4cgP8ac/d2F+SpC8mXPiBuDxqRNhMmrn4VWFXrFubvj2NMi vIL9lnOHVMzd9pHBSxEzaHLqoW+YxR70CD9NMd061iDFXZLjbLnr/wzGYYUn7p+vUTsJ PtznbQRDn3BbbwMRB3TJWAeFWAt366kXfPxglAofbs7WJnK7lSNLNLHDAbr+QkcwAVgQ i24w== 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 e9-20020a056402190900b00418c2b5be54si1719894edz.310.2022.04.13.04.54.39; Wed, 13 Apr 2022 04:55:05 -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 S233719AbiDMISj (ORCPT + 99 others); Wed, 13 Apr 2022 04:18:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233713AbiDMISh (ORCPT ); Wed, 13 Apr 2022 04:18:37 -0400 Received: from mail.meizu.com (edge07.meizu.com [112.91.151.210]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A7A74AE27; Wed, 13 Apr 2022 01:16:16 -0700 (PDT) Received: from IT-EXMB-1-125.meizu.com (172.16.1.125) by mz-mail11.meizu.com (172.16.1.15) with Microsoft SMTP Server (TLS) id 14.3.487.0; Wed, 13 Apr 2022 16:16:15 +0800 Received: from meizu.meizu.com (172.16.137.70) by IT-EXMB-1-125.meizu.com (172.16.1.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Wed, 13 Apr 2022 16:16:14 +0800 From: Haowen Bai To: Geert Uytterhoeven , Michael Turquette , Stephen Boyd CC: Haowen Bai , , , Subject: [PATCH V2] clk: renesas: Fix memory leak of 'cpg' Date: Wed, 13 Apr 2022 16:16:12 +0800 Message-ID: <1649837773-3501-1-git-send-email-baihaowen@meizu.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.16.137.70] X-ClientProxiedBy: IT-EXMB-1-126.meizu.com (172.16.1.126) To IT-EXMB-1-125.meizu.com (172.16.1.125) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, 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 Fix this issue by freeing the cpg when exiting the function in the error/normal path. Signed-off-by: Haowen Bai --- V1->V2: free both cpg&clks drivers/clk/renesas/clk-r8a73a4.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/clk/renesas/clk-r8a73a4.c b/drivers/clk/renesas/clk-r8a73a4.c index cfed11c659d9..5a8d976f49e0 100644 --- a/drivers/clk/renesas/clk-r8a73a4.c +++ b/drivers/clk/renesas/clk-r8a73a4.c @@ -215,7 +215,7 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np) cpg->reg = of_iomap(np, 0); if (WARN_ON(cpg->reg == NULL)) - return; + goto out_free_cpg; for (i = 0; i < num_clks; ++i) { const char *name; @@ -233,6 +233,9 @@ static void __init r8a73a4_cpg_clocks_init(struct device_node *np) } of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data); +out_free_cpg: + kfree(cpg); + kfree(clks); } CLK_OF_DECLARE(r8a73a4_cpg_clks, "renesas,r8a73a4-cpg-clocks", r8a73a4_cpg_clocks_init); -- 2.7.4