Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3533708pxj; Mon, 24 May 2021 08:50:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbgvLV++lxaJOKfnImzDyfTALV8k5nr5AKyDBP5S4B3pyrWY18Bx0COv1EOPg3B9DeNvpT X-Received: by 2002:a92:ca0e:: with SMTP id j14mr14539095ils.271.1621871440379; Mon, 24 May 2021 08:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871440; cv=none; d=google.com; s=arc-20160816; b=dUPyI//bJOMa/pciLNL0X9vd2HJmT5n4DbQLRzL8OFwJFnCCBPE48pJXBkYY7uqLcN RRDCEDssHCN5mdnotkdzpAUaEENBJW0a46b/bjGYgjAoRs+XFfDjkN2MU6ZAK+YM6MiM 2pbymGABP/EynZbIrhR3GCKdt8qrp7wOy4mQnOVDLH1tl2ftjtVNodpxg7F9JSl4i2oG qGAD9tXlRcajb1alWnhAFxDxUIKdqzKp76uSXafxrOM6BSo4yNxsaZzPLsA9RmXXPaqt keRfrQfOAptpFIErt8aSR5UXoTwIfC3MLzzO/6djahjiewD6ILN0OKN2vmEoSULfY8jF O37w== 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=jGYVHWZaWA4EnR6k6mGMcIvDJromW9uYC5AlsNqplTUVuQTVhyXv6v7qte0X3Tf3jy uCRu/AVhneAf+4ImFaKgSKtzHOA93jIiMDXjUeRxuQC3l3/gh/Ztyxd3JIVLJZNj+VM5 BWgLyeRM1gkZapufNckF9H5Wq7n7IyGVnHbCwExpxZTyAAyITDOI6sTUMvsFTXf28e/r 5GiSNl4pbqEyX/VvaIJy2B3SOOezwowtgbfbWiRB/iHwcFZQfLjZHdPHAPhYKpaAyEip 9ut6ROydNL4JMrhTyOsNkuCs20OOGAEi1f02nv4VmtTIlbHLB4S3Nj7ZFZmLjE1fAxXF cxTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="R/+xddu3"; 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 h17si2170870jas.28.2021.05.24.08.50.27; Mon, 24 May 2021 08:50:40 -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="R/+xddu3"; 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 S234101AbhEXPvU (ORCPT + 99 others); Mon, 24 May 2021 11:51:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:33896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234570AbhEXPoY (ORCPT ); Mon, 24 May 2021 11:44:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7FA256144F; Mon, 24 May 2021 15:35:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870556; bh=TNxXa//VQgKbqojkS+8vIrKVZ1my+B8M9BNV93vhruU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R/+xddu3guULuNQ/A8XKPHzEN3XqcUw/18hANiIRntjZacnGwmR80LlSkW1QsjSZd PiYaG5XTeKdGL82+xl599ML+VxXji5KWW2zhoXaMxEbYM4GU5GzfSsSfik5rPXqQfU yaKCGBzpKr66fi8g4sA3m1rK0oBVeYM12IOkaE1E= 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.19 40/49] net: stmicro: handle clk_prepare() failure during init Date: Mon, 24 May 2021 17:25:51 +0200 Message-Id: <20210524152325.664910387@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.382084875@linuxfoundation.org> References: <20210524152324.382084875@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)