Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3542752pxj; Mon, 24 May 2021 09:02:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+5OQsMUvb8dqVsl2/RpYJdjHzUOPK/8SyrnsWj1VDnegFCY9MuIbNUekQNu3cer5rlPtr X-Received: by 2002:a05:6638:1650:: with SMTP id a16mr24764476jat.23.1621872131203; Mon, 24 May 2021 09:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872131; cv=none; d=google.com; s=arc-20160816; b=o7c4izZxUxzPF6YY2MXOUenKCESJ9E9ZhEso5G9UsA+qhqHef0OT54ZUbdwBhGucW3 XVnQq64UkSr4b6k70wAA+SboMwmN2qmxVe/QED7q5E2JPs6r59f90Iknl7SByDghYerb mPdnXDzCdWN5609Tq82Q3aS+v3nF1KeaYyB7r56Np22ccVDvaoHZLdpSbOSHcqYcZY9P wbnGvg14Ki7RDO5XBk3sGBMfZujmjvMEkE1VlhS5AoXuIORUHhJEkGzeDhCbXmhf+M01 NCQNF88PaRlgI8ICTcOoIDSBZ7SleO2GjH6SlBZJsFLrwv0ICjOquNPc2dHEz7uz22mW Umyw== 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=fupJ/BZPpXgZGTjvA8IGHkNQ3N0ccyWaDr8nlP2p2QQ1GNiTeS79gm5O77MkWdJwAB Je3OUU4Q157ma++oApFy3mnwzdtiltbjhsjynHLmDlS49IIVFEKqgLu1VyPsuDB+kMv3 YoCfKZVwa+Buv3C0QLxmitBA0CEHvMr/uGCXXLukxx2cuTrGd9Q5qt+DhUR2xhmyvhnJ V19S2vw8rT6Zi6VwMjiZaOU5rXeiyeOiRS7DWM1Atl/94o2OptrlyXI1t6uMcGL+gVRr Ov4I+LjaRq6k7Tki7ytULnLfNeYZpqZamFhKsOW3T6kvOlK18ui86mMMqENvUR4b9nWs iPdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2i0qf71a; 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 j8si15239705ioo.10.2021.05.24.09.01.55; Mon, 24 May 2021 09:02:11 -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=2i0qf71a; 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 S234718AbhEXQCq (ORCPT + 99 others); Mon, 24 May 2021 12:02:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:40474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234966AbhEXPz4 (ORCPT ); Mon, 24 May 2021 11:55:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9215261945; Mon, 24 May 2021 15:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870940; bh=3eB4CpqZbQMODAApH7fn0fg282KuU6e5dh0PHqES+io=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2i0qf71arkVrKBSguJo3DMF9QKyCLw98H6tUTFMFPhhwMX4wZFuN8P8QDdr27aIkt zjMPtLsBB6AaZaPEfCLKGY8RDpRGtUTeo5w15QhwutR6OmdjrQSaUCExUeKt+notKw iyfgIsuJxxIjQPUiplG+awJHu9w/t+oLHfx/RMLM= 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.10 088/104] net: stmicro: handle clk_prepare() failure during init Date: Mon, 24 May 2021 17:26:23 +0200 Message-Id: <20210524152335.768401930@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152332.844251980@linuxfoundation.org> References: <20210524152332.844251980@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)