Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1374914pxb; Fri, 20 Aug 2021 04:18:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvFq+9dKyP5YaTzvtMPmFF8g1jP3HvS+Zy/Qsj9/tK/x99nSABdFLloyLCupwQf6TSfGOD X-Received: by 2002:a92:d20d:: with SMTP id y13mr10340319ily.294.1629458311079; Fri, 20 Aug 2021 04:18:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629458311; cv=none; d=google.com; s=arc-20160816; b=n9dIfj8/LSev0ZKNwiGu1yaD+CxlakSbjwy8UH8XQR1K36fsg7gI5dUgX9izfM0Av5 TGWBGNJnp/U3PKZrOydDZFrDIcgVH1BTvADLrs9d5ye1sVgFsff9V1kXcgMDwHA0v+rq wx7mi6POTt2RRbiGcqdRfR+CV5yGPPFIMya3d1jxMZtb85YUYFUs4vntmll8J9uHv+EV 0+Bq4zDHJrK3kR9t/1FRo3UvnaJHMHIvRdDo9+GAcMZvE+gDkOUnNI+/1pbexfzjSLb2 I80Wkx9vWB7mf3Ixv+E2dRWzcf+Je+F1dSgHidwpzxBfODTpF1vaBDNtHGraWgbq4Lfn eAcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=721KzYea4LA4jXv97w9zu7mZ93fjVviTrhuZoBooyCI=; b=POy7ftJ8eM18+a5deEjNkPhsX03LCaVZ4nIAbstZ8DnfrzeIfACdQDOwpbrNjFJAjf 0l5P09nFFyM4LzZvoWA/rEXFvzsPRVYrx/z8A3ChRgTkT/ys6KLjbbiQjZK2hjgge9pU uEsis+pJty18gwcQCjyVvcXGtvpU9sjya4SHJQVmGRomb3KGrmXMQg54evJnY999t1tz GBeMtNMNJ5OZreO6htONv/G+DQZw9Nh1VTRQ6pkAd9D5iGl0K5dONDGtFzpmvLbmKIDH kVij9F/cdLXZLmJuTYvHi9miecfNPIuW8iNsgy91eJq66GRWneJFSjzyyYypqpHDQaiC T/9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m6si6651173iol.83.2021.08.20.04.18.19; Fri, 20 Aug 2021 04:18:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239832AbhHTLRp (ORCPT + 99 others); Fri, 20 Aug 2021 07:17:45 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:42998 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S239727AbhHTLRn (ORCPT ); Fri, 20 Aug 2021 07:17:43 -0400 X-UUID: b2d85eab94754a0993fd1d3c56d90ed9-20210820 X-UUID: b2d85eab94754a0993fd1d3c56d90ed9-20210820 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1941171218; Fri, 20 Aug 2021 19:17:01 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 20 Aug 2021 19:16:59 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 20 Aug 2021 19:16:59 +0800 From: Chun-Jie Chen To: Matthias Brugger , Stephen Boyd , Nicolas Boichat , Rob Herring CC: , , , , , , , Chun-Jie Chen Subject: [v2 05/24] clk: mediatek: Fix resource leak in mtk_clk_simple_probe Date: Fri, 20 Aug 2021 19:14:45 +0800 Message-ID: <20210820111504.350-6-chun-jie.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210820111504.350-1-chun-jie.chen@mediatek.com> References: <20210820111504.350-1-chun-jie.chen@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Release clock data when clock driver probe fail to fix possible resource leak. Signed-off-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mtk.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index c3d385c0cfcb..74890759e98c 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -314,7 +314,15 @@ int mtk_clk_simple_probe(struct platform_device *pdev) r = mtk_clk_register_gates(node, mcd->clks, mcd->num_clks, clk_data); if (r) - return r; + goto free_data; - return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); + r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); + if (r) + goto free_data; + + return r; + +free_data: + mtk_free_clk_data(clk_data); + return r; } -- 2.18.0