Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3525768pxj; Mon, 24 May 2021 08:39:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzH0yMP8owygbo5OM+Hxczl4MCXAvijgrViZoVmkPrOG8yiOLCc5VcpWVw0I7JqhkSSkZhd X-Received: by 2002:a17:906:7e51:: with SMTP id z17mr23818548ejr.2.1621870777992; Mon, 24 May 2021 08:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870777; cv=none; d=google.com; s=arc-20160816; b=BxyqKapjuWzbwcBtGbd+QSXhUghBP8dQrn3UWAZE5PNWoXcO91n0dkbzs0tkp8KqrY 0BUu7lGuFUFQVsCcVSW6vbLmhG7awDwlBo8DEhh2Ntrf0N2+0TJGkpsjl4IyK7RSKlFJ nYuT8cnWUvzee8LYxwnea3aBYGUAlYpPBE7RknuOXdM8H9b9lACypKBjTDTEP3HEwALT owOJs0JEN5K9aFTqS4WG8femVjGyOVRteKh20H1qb2A0Fe9aw1ZTFSvwT02+SBN9MIgf FjSZtztN7mRL6iWQYwaD5iY7zP2bedbFPBrNLNRp70SCZSu7eNKr3RHWewLaKCvdsDjG GwMA== 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=sPTwTM8jRUfOO4bve85BHuw73KfJfJC+3IbZnbIVWGG2CuCwsSqHcUPWqUP9Z0HpvN tnq1MyBWYCSFb/hbWMvqLtQUl6Q9JSygrxN5FlLUMYIKSKqEtGsF/8ZSnXqRvL72HKjh YB+3fnGgUv63oXtxkwxdfAh/djhHhf+ffyH8uh3cWIfeQWtapSKxy9uhUvUQoESdYvST CthId1qsNOEtWdR0uf6yN5m4uj7ql4mdP1hLxhTFEOPx79uec8PeQbzoOWudAQlcoKKl ajtu87384T99woE6S5of4wob2qHRI6Io8cJWKLcA9o/aSKiPmDPg6YuOM4crCuraD7Nk 2PCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=crFQbRsv; 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 e6si15599945edz.248.2021.05.24.08.39.14; Mon, 24 May 2021 08:39:37 -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=crFQbRsv; 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 S233116AbhEXPjt (ORCPT + 99 others); Mon, 24 May 2021 11:39:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:50508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233378AbhEXPgr (ORCPT ); Mon, 24 May 2021 11:36:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AFCD061417; Mon, 24 May 2021 15:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870375; bh=TNxXa//VQgKbqojkS+8vIrKVZ1my+B8M9BNV93vhruU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=crFQbRsvqtV8W83UrWQXsb06FMMR7rx445ePTt21eSrxD2f9uLlrMwcZCmloCt/MQ s9jHi3wtZJ1XMI1RFEtrM6i6ptNjleX12H/a9h/moB34tKqCRWI+TUSUzClt3wziaz 5o+uw7sopfPqCuFRl4oAZJ6m4EIri5h+pcwyRvC8= 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.9 28/36] net: stmicro: handle clk_prepare() failure during init Date: Mon, 24 May 2021 17:25:13 +0200 Message-Id: <20210524152325.070890429@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.158146731@linuxfoundation.org> References: <20210524152324.158146731@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)