Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp113369ybg; Mon, 8 Jun 2020 17:59:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz5sAgjWuqh6EVKYguLAckk+t13ILQM/SLW/poMcTwvcf87nM2rJZ/JpxTAHbQwQei7nyr X-Received: by 2002:a17:906:90d4:: with SMTP id v20mr22647716ejw.471.1591664366926; Mon, 08 Jun 2020 17:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664366; cv=none; d=google.com; s=arc-20160816; b=lRcTjFonzmYj+QhB2exb3/veOafErQO/VTnXvz6EM7fFIUfum1lgDntThSkTBCye3X BT6L02hnVPC2XA6zVsNfGnGnK/ZXOgj7MPg2nspj4JmQQJ3hZ0wK7JMr/McnIblgfS8A gjVJ9twC8c7DTqwcfFzl0bS1G4+2OSOoSo8oHYMJ7rR6d1VB5+jIY7wkKvXJP7A/9z8g UM0jbDlFvsmqrqtjcBRpasYv1BWoHvM5a9zFssCH+DRUl0Wm+ldU2kpeXDK/QOoadCkd dtH07p1hjYPmAAcfnU9qfezxzL7r4hQjb3645kvqk01L9JSZ/0FttA6j28+ohWNtfsk+ Cyng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bsVhYI+KntngJmsoa8+UE9EAjduHQDunaXCMZOTXtQk=; b=Kw6j+8Kf8AeyGhUqSORca5/qxCoYCSC9oIEnt/Tb4/lmZHhRXfdxss1aCFGS5a8XNC ibpTo+4Da8rgosAoZw5U5xKKEF2At5Syl1qm+DPMg6+6p2ee5gqr61AQkXE9n1Yorr5X eJfxOPa9Nm0DbxMx9kRF5rEdEolsxsK0TqScxcqBsvc9R9vnS10vXpFgJWFgu8McRAJE qv0mA3VGJyKI9KK9rkCPVC9DXD+G31ebQ7auFyz7WbfRyBXh4TZZbaz2RB/07Yub2dAS oyJGqOVOD4z5FYNvOguQxaJAX5LcMQBBp9G8X52pbqVrpByBds+JTLrGfEiV6JKz2HAw B+hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QqJSJyLY; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zb3si6082550ejb.610.2020.06.08.17.59.03; Mon, 08 Jun 2020 17:59:26 -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=@kernel.org header.s=default header.b=QqJSJyLY; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387991AbgFIAzS (ORCPT + 99 others); Mon, 8 Jun 2020 20:55:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:55078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728406AbgFHXJV (ORCPT ); Mon, 8 Jun 2020 19:09:21 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6E61020890; Mon, 8 Jun 2020 23:09:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657761; bh=KO1X9m7NPmmKUMWAX5wnckaZR418zjtg/BYnrfIAY3Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QqJSJyLYdeazMZgOuSNTXYwUYrKmWGWKaCrGRUbyA1EjimHD+sQxUJAUBVMj0D7kn 1l4d9OwSHu9nUNTeOVO44HQSkpgQS84oJPzFG2nfWtaDdRNxH/uL8Acs+Q0xAqrR3C orVKFegMt+z0dieZWpMpcPIBxXxOsUqitUTiCdT4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andy Shevchenko , Voon Weifeng , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.7 146/274] stmmac: intel: Fix clock handling on error and remove paths Date: Mon, 8 Jun 2020 19:03:59 -0400 Message-Id: <20200608230607.3361041-146-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Shevchenko [ Upstream commit 09f012e64e4b8126ed6f02d0a85a57c3a0465cf9 ] clk_prepare_enable() might fail, we have to check its returned value. Besides that we have to call clk_disable_unprepare() on the error and remove paths. Do above in the dwmac-intel driver. While at it, remove leftover in stmmac_pci and remove unneeded condition for NULL-aware clk_unregister_fixed_rate() call. Fixes: 58da0cfa6cf1 ("net: stmmac: create dwmac-intel.c to contain all Intel platform") Cc: Voon Weifeng Signed-off-by: Andy Shevchenko Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 20 +++++++++++++++---- .../net/ethernet/stmicro/stmmac/stmmac_pci.c | 5 ----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index 2e4aaedb93f5..d163c4b43da0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -252,6 +252,7 @@ static void common_default_data(struct plat_stmmacenet_data *plat) static int intel_mgbe_common_data(struct pci_dev *pdev, struct plat_stmmacenet_data *plat) { + int ret; int i; plat->clk_csr = 5; @@ -324,7 +325,12 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, dev_warn(&pdev->dev, "Fail to register stmmac-clk\n"); plat->stmmac_clk = NULL; } - clk_prepare_enable(plat->stmmac_clk); + + ret = clk_prepare_enable(plat->stmmac_clk); + if (ret) { + clk_unregister_fixed_rate(plat->stmmac_clk); + return ret; + } /* Set default value for multicast hash bins */ plat->multicast_filter_bins = HASH_TABLE_SIZE; @@ -657,7 +663,13 @@ static int intel_eth_pci_probe(struct pci_dev *pdev, res.wol_irq = pdev->irq; res.irq = pdev->irq; - return stmmac_dvr_probe(&pdev->dev, plat, &res); + ret = stmmac_dvr_probe(&pdev->dev, plat, &res); + if (ret) { + clk_disable_unprepare(plat->stmmac_clk); + clk_unregister_fixed_rate(plat->stmmac_clk); + } + + return ret; } /** @@ -675,8 +687,8 @@ static void intel_eth_pci_remove(struct pci_dev *pdev) stmmac_dvr_remove(&pdev->dev); - if (priv->plat->stmmac_clk) - clk_unregister_fixed_rate(priv->plat->stmmac_clk); + clk_disable_unprepare(priv->plat->stmmac_clk); + clk_unregister_fixed_rate(priv->plat->stmmac_clk); for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (pci_resource_len(pdev, i) == 0) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c index 3fb21f7ac9fb..272cb47af9f2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c @@ -217,15 +217,10 @@ static int stmmac_pci_probe(struct pci_dev *pdev, */ static void stmmac_pci_remove(struct pci_dev *pdev) { - struct net_device *ndev = dev_get_drvdata(&pdev->dev); - struct stmmac_priv *priv = netdev_priv(ndev); int i; stmmac_dvr_remove(&pdev->dev); - if (priv->plat->stmmac_clk) - clk_unregister_fixed_rate(priv->plat->stmmac_clk); - for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (pci_resource_len(pdev, i) == 0) continue; -- 2.25.1