Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5724918imd; Wed, 31 Oct 2018 00:40:46 -0700 (PDT) X-Google-Smtp-Source: AJdET5fDuJKBli4tZIDiKvQsFqzNcQKbTFzmtK/c9wSVTomqYWJfEBIuOrj0GbXXvKHvhQVQMIm0 X-Received: by 2002:a17:902:ea:: with SMTP id a97-v6mr2182659pla.164.1540971646741; Wed, 31 Oct 2018 00:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540971646; cv=none; d=google.com; s=arc-20160816; b=A10F6tnxat78IcadstPuQr32m53Y08A2O1sXT7xST5iEU8OeMcQHnfw11rSJPyZYh1 Xa9p3el5/LbHNfpjpIdbiF8PeeEYtbEdAkV9LPDT4LgKCFT6KmzZH1Kjh5cBAeyAmD7I 8IK0hoRYrDLCjf4cK39j591MxRRhYQdGfp/H6H6VIJuwGlo1HCtw4lNOU3F3o7jEGhV1 T83+seTpeE0M0vxR6OP5a41E+Ls/EzqaPIFCoGt05+lSn31/Upr2DLMKDFZLA5nSpkGR sMMdH0sNCuj9fv46WrexdP6cKsxyyzJ2cfoXrwT0Rwl5frUAlRWXeYQIhmYccuwqsMoy KtNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=xWs3w979GH3Mj9HCJQb1mXTaLJRVRVUMvpwxKojvr+c=; b=LtgaCcTO0RfHEna+NBW+ofC+zctaiEJVXzR1aw4pYPCschKk00mSjsZY27WUitrE9x WNUJizBjP6e4omTD8dJJUoJmfWYnAMg+JbiOS7MtfIqRdKD9QMyIUl6AJSqmXfw6xsC3 G+GkEiDUut3lPoKJx9UPxlQTE7lBhm5O50vr0kgjEUFg6xSNgYS8FjDoSfeyJI2hy9Pa G/ujGlu2ZF7X7msVS+bWBzmZNQmxe/NuYK9uBT4OLVG7Qn0YPUnX8EQEwnN8DOvyYXYp ZkMxHfH6WGyJv0VqAo1hwAst62kZZRf1wd7Rh5FKhAdqIp8mavHXzTMTSniD/El+i3km HapA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1-v6si1980333pge.251.2018.10.31.00.40.31; Wed, 31 Oct 2018 00:40:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727168AbeJaQg5 (ORCPT + 99 others); Wed, 31 Oct 2018 12:36:57 -0400 Received: from mxhk.zte.com.cn ([63.217.80.70]:9538 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725955AbeJaQg4 (ORCPT ); Wed, 31 Oct 2018 12:36:56 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 2D17A2FBE1B380C802BF; Wed, 31 Oct 2018 15:39:57 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w9V7dsCK016007; Wed, 31 Oct 2018 15:39:54 +0800 (GMT-8) (envelope-from wang.yi59@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018103115401643-7800137 ; Wed, 31 Oct 2018 15:40:16 +0800 From: Yi Wang To: paul.burton@mips.com, sboyd@kernel.org Cc: mturquette@baylibre.com, linux-mips@linux-mips.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn, Yi Wang Subject: [PATCH v3 2/2] clk: boston: unregister clks on failure in clk_boston_setup() Date: Wed, 31 Oct 2018 15:41:42 +0800 Message-Id: <1540971702-3133-3-git-send-email-wang.yi59@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540971702-3133-1-git-send-email-wang.yi59@zte.com.cn> References: <1540971702-3133-1-git-send-email-wang.yi59@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-10-31 15:40:16, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-10-31 15:39:46, Serialize complete at 2018-10-31 15:39:46 X-MAIL: mse01.zte.com.cn w9V7dsCK016007 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The registered clks should unregister when something wrong happens before going out in function clk_boston_setup(). Signed-off-by: Yi Wang --- drivers/clk/imgtec/clk-boston.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/clk/imgtec/clk-boston.c b/drivers/clk/imgtec/clk-boston.c index f5d54a6..dddda45 100644 --- a/drivers/clk/imgtec/clk-boston.c +++ b/drivers/clk/imgtec/clk-boston.c @@ -73,31 +73,39 @@ static void __init clk_boston_setup(struct device_node *np) hw = clk_hw_register_fixed_rate(NULL, "input", NULL, 0, in_freq); if (IS_ERR(hw)) { pr_err("failed to register input clock: %ld\n", PTR_ERR(hw)); - goto error; + goto fail_input; } onecell->hws[BOSTON_CLK_INPUT] = hw; hw = clk_hw_register_fixed_rate(NULL, "sys", "input", 0, sys_freq); if (IS_ERR(hw)) { pr_err("failed to register sys clock: %ld\n", PTR_ERR(hw)); - goto error; + goto fail_sys; } onecell->hws[BOSTON_CLK_SYS] = hw; hw = clk_hw_register_fixed_rate(NULL, "cpu", "input", 0, cpu_freq); if (IS_ERR(hw)) { pr_err("failed to register cpu clock: %ld\n", PTR_ERR(hw)); - goto error; + goto fail_cpu; } onecell->hws[BOSTON_CLK_CPU] = hw; err = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, onecell); - if (err) + if (err) { pr_err("failed to add DT provider: %d\n", err); + goto fail_clk_add; + } return; -error: +fail_clk_add: + clk_hw_unregister_fixed_rate(onecell->hws[BOSTON_CLK_CPU]); +fail_cpu: + clk_hw_unregister_fixed_rate(onecell->hws[BOSTON_CLK_SYS]); +fail_sys: + clk_hw_unregister_fixed_rate(onecell->hws[BOSTON_CLK_INPUT]); +fail_input: kfree(onecell); } -- 1.8.3.1