Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3524248pxj; Mon, 24 May 2021 08:37:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDIrMTmmAApgCD6nvRyahobb/3oWoTvzD2ReOwc9guMOvCoDHCqkxHiF8lcV1gB32/POVg X-Received: by 2002:a05:6402:34c8:: with SMTP id w8mr26489054edc.243.1621870654593; Mon, 24 May 2021 08:37:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870654; cv=none; d=google.com; s=arc-20160816; b=XWBhCorkn5+lZ30qP8yAYnlH+dU4GjRSpdxOvedF7FF/rCrHNULmOk/dLT8Yt0Lw9p JiDDwbjryNd12qtrd/Pq09hadwutTgK6F4Wjt1QRK2OMXS540KrqZAYL3pVZQiu8czJ0 ODue70N6inD06EoyR6DQ31Hl3VMU0F7IO15Jw9mzyd/0NzZJg+ySMQHHB0CBn3W0mito 9nX55SkHafk8ZkHV48UNXPE1OudJVR0608zCeoaCSjigxMJVZkOfOT/LA8GG79dnCrGe 2ZN5C0nPPKRj5Zm3OExD+WqCxGEDzJVnpEOweWP7HDflcbw+sJ3kPSHH326t3LVJT5+8 q7rA== 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=huL1aGPs4HyoLI3AOH3XdPJvlMqkEKmsdPNKHUy1ruk9jjsdJWAR4/a34mKNowuEEb VgVBwoY1wA5Y/qCXBZNf6CptHZeNgfC9hAYZauBfzSjS0brzZO8//DFuJNy7URrFwNi2 2F1htK/oD1m8YEYEd/vy6qEvEEBUu3TSIoM43lTRRQhSIPZrdUMbA08A6m7J0eDHM9B/ m7DFnNumb/BmYmobRoPHp4dAiGeSDBcbwDG0biNm7Mmf0LZW7z0el9T8UEvQb8TR6DgF +YPdrLzjPZAJI9s+7Fl4BStkwimq3FPC+AytI2BymhSmeE5His8RgMZ/YOyc0hHFqA9E RfrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2Uh9BxlB; 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 bo24si12579123edb.374.2021.05.24.08.37.11; Mon, 24 May 2021 08:37:34 -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=2Uh9BxlB; 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 S233837AbhEXPgN (ORCPT + 99 others); Mon, 24 May 2021 11:36:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:51348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233311AbhEXPdb (ORCPT ); Mon, 24 May 2021 11:33:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 94F8E613CC; Mon, 24 May 2021 15:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870267; bh=TNxXa//VQgKbqojkS+8vIrKVZ1my+B8M9BNV93vhruU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2Uh9BxlBlGWjhMXdQwE7ko88Dzy7bTN1FYS3vvWJtuTBylnwaXJoWKw5SKGVm2TJp KaV12jXLpl4ZPS2iBDBSaPNZjvid/PGBagQJtTXze5hiqLsUcSnNSRvuK4Y1edZ5on QHY8NDnAYlbtT7tWny/iQY/V2NI6zugLtqMxczxk= 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.4 24/31] net: stmicro: handle clk_prepare() failure during init Date: Mon, 24 May 2021 17:25:07 +0200 Message-Id: <20210524152323.711789450@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152322.919918360@linuxfoundation.org> References: <20210524152322.919918360@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)