Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp332185pxb; Wed, 13 Apr 2022 01:58:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzRVGt/X42GMSStgkG580KvJC1dnq0WAA4UGF6MQk9CBghO0G4I0v7eBe+cjIVmRetotqL X-Received: by 2002:a17:90b:1803:b0:1c7:24c4:ab52 with SMTP id lw3-20020a17090b180300b001c724c4ab52mr9495916pjb.240.1649840333758; Wed, 13 Apr 2022 01:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649840333; cv=none; d=google.com; s=arc-20160816; b=ezW5euzEtNcywA+IfnEfPy530xQVvOF7X/bMosx1DFaQsbLQAqxxqAHTt1xrlSWEYJ 8rov11MNYF/tWM3CJg8B98JfG5JuRaamEW1bi8aDviwnAZpvYQ9enEalZTSbFa73CqBP T/F5jMuTKnTvLSqUvqLcxiLpPEhPJWQ43gZamb1OAH3XK0iF55TosCUkIURxnufV7Jl0 Ja/hf+DhpTg01gbIc4OsRpC398cqxCRV8MO9glMWK69zMLCyZxqQtQxfU+kdwsxCvwXE F/nOUWUA75KiEU4ZV/OJENkfyEXbQZm69fPhZN1Ob7iLgm+UVXS8/6+4Y7kmmdUjBoVU XP+Q== 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=elbPFepMyCHxhY3ffVczEvK/JariqYvHuvlZktmme6A=; b=wm/ehiVdPBIzowIqKczHDHG07kZ+d3l2XbBXYzlAOeZQm5a3hWTKQziYMPGjXoIBzo ne5tw58dfGivYGvPUcCJAH1ZGxMRW4P2bfYDmE4BXvgz0P5JAJTFqJPeGpJDlBUpGJPD YUQWB5j+ug+wYmt1D1ZB453LlAbYKvXKRiNaIjyj1lJ9X2tJfC2bfa0wzP0KYKooqD1v 75AXczIeVNvijXhT9cX7n0eUwxHLWWFfLiXr2Jq+rlWhx9/3fITuuQ8TZQCDsDFThpqz X16mbaOblojWs9nUd9Pi8M7vzUDKt8IFBzRsZ6n3FSc2Pt4Mc2G71yXFaK52XiZSX7RK QS7g== 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 r69-20020a632b48000000b0039d61d31f02si5125425pgr.50.2022.04.13.01.58.40; Wed, 13 Apr 2022 01:58:53 -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 S233655AbiDMIVl (ORCPT + 99 others); Wed, 13 Apr 2022 04:21:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232770AbiDMIVj (ORCPT ); Wed, 13 Apr 2022 04:21:39 -0400 Received: from mail.meizu.com (edge01.meizu.com [14.29.68.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23BAC5F5B; Wed, 13 Apr 2022 01:19:17 -0700 (PDT) Received: from IT-EXMB-1-125.meizu.com (172.16.1.125) by mz-mail04.meizu.com (172.16.1.16) with Microsoft SMTP Server (TLS) id 14.3.487.0; Wed, 13 Apr 2022 16:19:16 +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:19: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:19:13 +0800 Message-ID: <1649837953-10984-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.2 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no 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