From patchwork Mon Dec 11 23:13:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Branislav Radocaj X-Patchwork-Id: 10105947 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EB256602B3 for ; Mon, 11 Dec 2017 23:17:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDB0729915 for ; Mon, 11 Dec 2017 23:17:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1E1C29932; Mon, 11 Dec 2017 23:17:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5507729915 for ; Mon, 11 Dec 2017 23:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=WpzgMXNsQd9xCKdpVPCJOeCWkWh+znfERnixye9i5Jg=; b=j97 YxyMn0OHcPABBkRlrrDYKfB2PLA4/dR+u+dIYXRzNt3oGRH/ahuS6gUvqf65iDaERAu2/BJqxFt1k BJv54qVaVFf0l3755RciQZ4YdLQ2bSU0sMv/G758Rswg0M6sVowk3rDXoY+IoMYg0XYSZo0aBzljL NwsrVL10xbBTA3wNaRNWP3OaeU3BxylVQyB0skIyoOT/2hvbmxRfW7jWeepKV/C0+3omfLm96DKNV tWldJf314XpS4tAVBARK17g1PUV01ZUMZGlvWI7sjz/eK+OhskdhBrHA7o9UTzyFelt2/zfZDsJcB WNyzPAWhEuE6z1U9R9yx02nPAYwnBFg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eOXJk-0006v5-Ar; Mon, 11 Dec 2017 23:17:00 +0000 Received: from mout1.freenet.de ([2001:748:100:40::2:3]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eOXJP-0006NJ-VH; Mon, 11 Dec 2017 23:16:42 +0000 Received: from [195.4.92.142] (helo=mjail2.freenet.de) by mout1.freenet.de with esmtpa (ID branislav@radocaj.org) (port 25) (Exim 4.89 #1) id 1eOXIx-0000qQ-Fx; Tue, 12 Dec 2017 00:16:11 +0100 Received: from [::1] (port=55568 helo=mjail2.freenet.de) by mjail2.freenet.de with esmtpa (ID branislav@radocaj.org) (Exim 4.89 #1) id 1eOXIw-0007YV-WE; Tue, 12 Dec 2017 00:16:11 +0100 Received: from mx6.freenet.de ([195.4.92.16]:36448) by mjail2.freenet.de with esmtpa (ID branislav@radocaj.org) (Exim 4.89 #1) id 1eOXGh-0004Gl-EU; Tue, 12 Dec 2017 00:13:51 +0100 Received: from p5b274a3a.dip0.t-ipconnect.de ([91.39.74.58]:52600 helo=debian.fritz.box) by mx6.freenet.de with esmtpsa (ID branislav@radocaj.org) (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (port 587) (Exim 4.89 #1) id 1eOXGh-0000v3-Kc; Tue, 12 Dec 2017 00:13:51 +0100 From: Branislav Radocaj To: heiko@sntech.de, netdev@vger.kernel.org Subject: [PATCH v3] net: ethernet: arc: fix error handling in emac_rockchip_probe Date: Tue, 12 Dec 2017 00:13:38 +0100 Message-Id: <20171211231338.5207-1-branislav@radocaj.org> X-Mailer: git-send-email 2.11.0 X-Originated-At: 91.39.74.58!52600 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171211_151640_222583_B1B73F3F X-CRM114-Status: UNSURE ( 6.67 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Branislav Radocaj MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If clk_set_rate() fails, we should disable clk before return. Found by Linux Driver Verification project (linuxtesting.org). Changes since v2 [1]: * Merged with latest code changes Changes since v1: Update made thanks to David's review, much appreciated David. * Improved inconsistent failure handling of clock rate setting * For completeness of usecase, added arc_emac_probe error handling Signed-off-by: Branislav Radocaj --- [1] https://marc.info/?l=linux-netdev&m=151301239802445&w=2 --- drivers/net/ethernet/arc/emac_rockchip.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/arc/emac_rockchip.c b/drivers/net/ethernet/arc/emac_rockchip.c index c6163874e4e7..16f9bee992fe 100644 --- a/drivers/net/ethernet/arc/emac_rockchip.c +++ b/drivers/net/ethernet/arc/emac_rockchip.c @@ -199,9 +199,11 @@ static int emac_rockchip_probe(struct platform_device *pdev) /* RMII interface needs always a rate of 50MHz */ err = clk_set_rate(priv->refclk, 50000000); - if (err) + if (err) { dev_err(dev, "failed to change reference clock rate (%d)\n", err); + goto out_regulator_disable; + } if (priv->soc_data->need_div_macclk) { priv->macclk = devm_clk_get(dev, "macclk"); @@ -230,12 +232,14 @@ static int emac_rockchip_probe(struct platform_device *pdev) err = arc_emac_probe(ndev, interface); if (err) { dev_err(dev, "failed to probe arc emac (%d)\n", err); - goto out_regulator_disable; + goto out_clk_disable_macclk; } return 0; + out_clk_disable_macclk: - clk_disable_unprepare(priv->macclk); + if (priv->soc_data->need_div_macclk) + clk_disable_unprepare(priv->macclk); out_regulator_disable: if (priv->regulator) regulator_disable(priv->regulator);