Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3528109pxj; Mon, 24 May 2021 08:42:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcpJ8wsels3jAFmTmmnFki0ihCETizKVtN6YDkUZzZDeCs24lhBnJ7h3upnJqfabOf8sPl X-Received: by 2002:a05:6638:258c:: with SMTP id s12mr24782688jat.92.1621870970585; Mon, 24 May 2021 08:42:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870970; cv=none; d=google.com; s=arc-20160816; b=JYB49Rr4FBWsgAxnR/wISBXMa/yl1QDqdmOzyTh4uyOOxyn6Ho0qVWy/HbQeb1jbmM Bk9ud5I93S8TwYG8g1TRHMWxLVBHAVajcyvcTxWHMAkMbwfZw4vP0uSCUh2F95PxLfE8 JxpmP91y7kaIWkZ8O094X+YqjRPum+WRA2qNpCePOxiWyHnCTnBra0bqxSivoa2XATdB t/FtlyLsYYYhFG/rcUNcQtz4Tj5ZE05PrdzwrZdsyc7zBWCcy3XLlFt5FW5B0pZsdVVn LIcL7pjn2JkG+so/X4Ltwwg/1AgDwc6JgeY3L0ANWxAR8muY91T74POY/c/OMV9yTJFu fJIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sQ+Kx8GTKKDlLTw1g+YfJggSkY3F+dp0pED09BlInRY=; b=Tnsmf60zQpZ0E6hCyeYGqNAXScsD04XsJUMECMEPnVrLDzX81CZfW4iJ04614Fkgj8 1xJhveu7p4O6ZxbBot0SEqewzOoaiuXtkxiZeG4fQxKXZGNTKU/OPn5tfX5Rif5KUBgF kCD6eSPeiCyGJd1Er/6giXidcrqUI6zXcf/M9MyEzOS0drPc2i52/xWEuMPm11/TVSF3 InK5pG7rJnxDDqr4gZfApAEpiKOSdvGZeNWl5Jc6tqtAKBsl9cpmyXuNxdm04PzATcKi fNxa0L91cObA+iWJYSOb1MgKWBCn6qx679CwP+ktc7kugB9lnAkepVD5FvsqNKGR/lKa 6Udw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0twaVkVz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x11si13752476ilp.53.2021.05.24.08.42.37; Mon, 24 May 2021 08:42:50 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0twaVkVz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234244AbhEXPn3 (ORCPT + 99 others); Mon, 24 May 2021 11:43:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:56970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233985AbhEXPjB (ORCPT ); Mon, 24 May 2021 11:39:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 20D146142A; Mon, 24 May 2021 15:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870431; bh=TNxXa//VQgKbqojkS+8vIrKVZ1my+B8M9BNV93vhruU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0twaVkVzuPMjHh7ORov8NFr0AILwZROOEU5LH5COcYWeRNw4NJdWCPk/yWm8oBKmX VoV9x6+e/idJdA7w5V03YUH+ktuVa6zGddWwAzeLRNYfXWZFsBfrzqJg6M8kTEHqUg bR2HkTeHnsTxvVCiFAs1oM9ZlhrzG+CK3JG+WaRc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anirudh Rayabharam , "David S. Miller" Subject: [PATCH 4.14 30/37] net: stmicro: handle clk_prepare() failure during init Date: Mon, 24 May 2021 17:25:34 +0200 Message-Id: <20210524152325.188252816@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.199089755@linuxfoundation.org> References: <20210524152324.199089755@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anirudh Rayabharam commit 0c32a96d000f260b5ebfabb4145a86ae1cd71847 upstream. In case clk_prepare() fails, capture and propagate the error code up the stack. If regulator_enable() was called earlier, properly unwind it by calling regulator_disable(). Signed-off-by: Anirudh Rayabharam Cc: David S. Miller Cc: stable Link: https://lore.kernel.org/r/20210503115736.2104747-22-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c @@ -39,7 +39,7 @@ struct sunxi_priv_data { static int sun7i_gmac_init(struct platform_device *pdev, void *priv) { struct sunxi_priv_data *gmac = priv; - int ret; + int ret = 0; if (gmac->regulator) { ret = regulator_enable(gmac->regulator); @@ -59,10 +59,12 @@ static int sun7i_gmac_init(struct platfo gmac->clk_enabled = 1; } else { clk_set_rate(gmac->tx_clk, SUN7I_GMAC_MII_RATE); - clk_prepare(gmac->tx_clk); + ret = clk_prepare(gmac->tx_clk); + if (ret && gmac->regulator) + regulator_disable(gmac->regulator); } - return 0; + return ret; } static void sun7i_gmac_exit(struct platform_device *pdev, void *priv)