Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2960926pxb; Mon, 17 Jan 2022 09:03:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwo4QZbKUO1NxyE4aPlWMar/c09HtlaN8UB12QsNGLhV3dtHIKgqkXzusDpntnZOInm6P5m X-Received: by 2002:a62:79c2:0:b0:4bd:e9da:c173 with SMTP id u185-20020a6279c2000000b004bde9dac173mr21937521pfc.65.1642438990933; Mon, 17 Jan 2022 09:03:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642438990; cv=none; d=google.com; s=arc-20160816; b=t4MXPB9GTA5irbxaZshHhNw0QrJXlIRpig+pTS0/lqnAgbeM5JORL5tzWiEtm6pezw IbL3jg+A/ELgqtEGX/hIIU2F5H3h5qUKsBlzuonQrKI5uMUGAe/MFgNvBFC6NTOLBySF PS49tJMYdQiZ0aVEvC+KCOkD5fyTZwm0PNxnWnE0VyAeMyK/gU4zP5Dq+crqJ4EEVYBp m/yrpGpneUjgs/Umen68lfMTS7nZuiAFopG256u529XAPgfG3B3QlTtcmy3PnhzOgEY9 t48HJuX8h9cfV/JMnkqNnL6hsc93qBN+zcAVTEaSSlDg5SxilZ9000yY/JXKzSXKU31i czeg== 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=dWfY3zyvkUaDTeCY/qbD+eL5lqmlNGaWfvHDnnyFTKQ=; b=PoKfCXXLm0TL/cdur5lpH6iLUORK0Kjk3YpIE3YZcVGP1Bfj32QG+puMh30vs3pogh X0egDnbhQagQWzsKprFkzsqar2u6i6d3P8CrOhS6LT9GRdnlFLGJszTNW9aj4pDKseJn tYtc4utPPzZgMSBf9Joz6RC/plzylu0NPfRAA3EQ9DRpnobMtH3fe/XPfASlt5QqzpRG qeewAe8xxDm6ZMwkjDehfgm/vQDffZ2bBp9TYVTn7UfmkxgMzM+e+/0l48GU/C+YgmCy orw1/4Rvr1uXDSYRiElTkCw67BPMacYQxlQUq+Q69p+x7u7kFfj0krYkz4e2IOnbZUNX pybg== 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 r186si14685907pgr.278.2022.01.17.09.02.57; Mon, 17 Jan 2022 09:03:10 -0800 (PST) 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 S233506AbiAQJAf (ORCPT + 99 others); Mon, 17 Jan 2022 04:00:35 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:59142 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229484AbiAQJAe (ORCPT ); Mon, 17 Jan 2022 04:00:34 -0500 X-UUID: ec0394411d204e49978411e812a1d059-20220117 X-UUID: ec0394411d204e49978411e812a1d059-20220117 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1176267212; Mon, 17 Jan 2022 17:00:32 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 17 Jan 2022 17:00:30 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 17 Jan 2022 17:00:30 +0800 From: Miles Chen To: Michael Turquette , Stephen Boyd , Matthias Brugger , Ikjoon Jang , Chun-Jie Chen , Weiyi Lu CC: Miles Chen , , , , Subject: [PATCH] clk: mediatek: add unregister logic to mtk_clk_simple_probe error path Date: Mon, 17 Jan 2022 17:00:29 +0800 Message-ID: <20220117090030.13064-1-miles.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Stephen pointed out that there is no unregister logic in mtk_clk_simple_probe() error path [1]. Fix it by adding unregister logic to mtk_clk_simple_probe(). [1] https://lore.kernel.org/linux-mediatek/20220114221930.660B5C36AE9@smtp.kernel.org/ Fixes: c58cd0e40ffa ("clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers") Cc: Stephen Boyd Signed-off-by: Miles Chen --- drivers/clk/mediatek/clk-mtk.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 8d5791b3f460..edf21975cb4d 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -161,6 +161,22 @@ int mtk_clk_register_gates(struct device_node *node, } EXPORT_SYMBOL_GPL(mtk_clk_register_gates); +static void mtk_clk_unregister_gates(const struct mtk_gate *clks, + int num, struct clk_onecell_data *clk_data) +{ + int i; + const struct mtk_gate *gate; + struct clk *clk; + + for (i = 0; i < num; i++) { + gate = &clks[i]; + clk = clk_data->clks[gate->id]; + + if (!IS_ERR_OR_NULL(clk)) + clk_unregister(clk); + } +} + struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, void __iomem *base, spinlock_t *lock) { @@ -320,15 +336,17 @@ int mtk_clk_simple_probe(struct platform_device *pdev) r = mtk_clk_register_gates(node, mcd->clks, mcd->num_clks, clk_data); if (r) - goto free_data; + goto err_free_data; r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); if (r) - goto free_data; + goto err_unregister_gates; return r; -free_data: +err_unregister_gates: + mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data); +err_free_data: mtk_free_clk_data(clk_data); return r; } -- 2.18.0