Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3539322pxj; Mon, 24 May 2021 08:58:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxf3usMWH3gTHw/jYjjqO7QCiWCpDW5shk35GS0WzsQbBFMriXdxWJo5qeR+nMF7Ih7HJm5 X-Received: by 2002:a05:6e02:df2:: with SMTP id m18mr16177208ilj.77.1621871898816; Mon, 24 May 2021 08:58:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871898; cv=none; d=google.com; s=arc-20160816; b=pWjoXPuFXnxoH7Welc0uHBtoFUyoaidssxRMWzHVGryio8aGJ8lvnAEvkfzgz4l/D9 hPOPL5wUGXsP3u2ZZHk3QsJgqbZjsbWJyK3uvyMfJm2xBn+zRlltkjPVphsE8IU0eIJv dKikCvag+4vDFVDX+kDPHJTD21xFgFutLV0zXfyLHviuHdJyUfwRw3mIKm9nY/+FH5eL ve7S2UHKtKVwu/X5oTUEHlGs4O/zGePVY0GdR/pcXgCkrYBBA5gLfMTV+LwIJNAJZa6c Ht04WIBuF3mj+R0Jd8mUz7mWLkSL/P5ppGW2lQdHMNFHNoaP9sbSBpLx3d8qwn5XFErL obnw== 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=g7okUKq9tbSCf41t+5Z2ecn3KsVSZNEq7LuB25rdXlY=; b=J6EUWArv68JkLcZm3ykt3pcQdbddvMJMLfF+rqMhpxLlpqswmSlOpVVbamLbnXGvKd uMfvfWpR6bHfNGGyN+AAbVdIj7e/WfCxGCeqUwYeWAEtwV4bmF1CInlNybvKo1m+kQlc J9f7kH4xYrxsvyqop8vztsZrr8L17qK+Ky3nR7Z28J/OhslDJsuHEKuPgrTZ3mbngSMx 5N1684V1Ga3CveLjBo+lXPPtl7lwCTcMlXBcS1fJU3AlahJxPBSvzhtoES/Rz3QhCi35 OQqoPIGapSKR2GDiqtarMxxY/Xy1sxzZIdGCCtCxIdfqlP1mV5QFPPUBeOwRPHHTrADD Lp+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u2HFcdHs; 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 b9si14194622ior.14.2021.05.24.08.58.05; Mon, 24 May 2021 08:58:18 -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=u2HFcdHs; 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 S235140AbhEXP5n (ORCPT + 99 others); Mon, 24 May 2021 11:57:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:39394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233114AbhEXPvW (ORCPT ); Mon, 24 May 2021 11:51:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 681F361628; Mon, 24 May 2021 15:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870718; bh=3eB4CpqZbQMODAApH7fn0fg282KuU6e5dh0PHqES+io=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u2HFcdHstfCozMLQu3qCjQ1nuoIvu9Y3LIIZLlKYSiWjoVmhAQbXwnz39yhkkLGrc upjuS5UQ/qi5ZpT97weh/g+mL0Sgrl94/NzKcycICrDrDVM0S3WWqiU/v3P3+UvoNe NMq7oczUzLYI5GbgPTzaORtEo+wzwg9C7jD2xMgk= 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 5.4 59/71] net: stmicro: handle clk_prepare() failure during init Date: Mon, 24 May 2021 17:26:05 +0200 Message-Id: <20210524152328.372204007@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152326.447759938@linuxfoundation.org> References: <20210524152326.447759938@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 @@ -30,7 +30,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); @@ -50,10 +50,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)