Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3550705pxj; Mon, 24 May 2021 09:10:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFG1ZzrRaR1rrOeS0O/rJI9ee0A1qofOpMojDI0reSy7RrApUTCuUx1mRee9TcihwHVXO4 X-Received: by 2002:a05:6e02:13d4:: with SMTP id v20mr16270150ilj.111.1621872639636; Mon, 24 May 2021 09:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872639; cv=none; d=google.com; s=arc-20160816; b=hehUF0QMMVo6jE9R/wrCGE0sDnaH/yMIjgzBJ4lO9Evz0+pS4ns7FA6TZg/7z4qepC XpwyMwNBhhgRIqK+0hDkZF8iykoUg1E/WHc1djouDFGqQx666IgYNn6LxPUmODavUySl MaaTDWMNDI3NydwzusTxHtT4ZLsHVXLaB2iBekWFV46mLt0aqll4Xn4O9nQSaozIBIn9 Bk1nbvUbpdKj3kbj5Uc9MZAjGPXw4wcmLS4Sn1AP+NUdPH6fOak6b3Kbn3xYBDmGIfxh WOVlfk9xiX1w5bFoE3eDSXGuGJO8OBQvhSbXL0bhH5zJEoXO40kME5VSxwBNPCyJhkld 8DVQ== 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=XTXGhbobBxLZnrMn35ZUbsCWbF4PwlwsHV6DVq/PvopoVpIylLqIK2Iqb3LD+iy5+K T4zhg82/NU8viZBiXRSP0oxqqAk6kXhOQlejmGNdX7tq9XRoUDFe7Aoj+ytCp4Y7/b9l /3HGDcQnVVoCKypNmLm4HMOMq9QedlwQGehRCNBdQdR35Fgp8FxEhMdNVzj24f73osAA FP2pCaVL7u0NSL8jskDprEL3wZAtwXhrFWToeoRUIDxZNjaQXn4iG2QwZPg3gJbIeEL1 3KJaTTkHres4tIdFzHrBH+Vot/1qB/w5o/WZ0lsjcMmqfkn7oXa/CCpfCgnL8gyxv+2f N+NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kEzCDW5z; 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 j13si4339022ilk.14.2021.05.24.09.10.26; Mon, 24 May 2021 09:10:39 -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=kEzCDW5z; 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 S236656AbhEXQI5 (ORCPT + 99 others); Mon, 24 May 2021 12:08:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:46588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235046AbhEXQA4 (ORCPT ); Mon, 24 May 2021 12:00:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D65AD6198E; Mon, 24 May 2021 15:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871181; bh=3eB4CpqZbQMODAApH7fn0fg282KuU6e5dh0PHqES+io=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kEzCDW5ziXuF6nxYbMYzzimMeBdg/JsrfK9wF0JjArgzFok4cfNkzemqBEJEc6nBf feqvEmnZmigOS+uq51Xr8WciQLYWSiEhsRAhN5wqC6uwi/hhBhi+aEMNCACZMkNlY2 nkzZezY7E9j88PkLmaPw40d4GTaYoDRyuSFhU49w= 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.12 111/127] net: stmicro: handle clk_prepare() failure during init Date: Mon, 24 May 2021 17:27:08 +0200 Message-Id: <20210524152338.611592474@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@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)