Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3493320pxf; Mon, 29 Mar 2021 03:56:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6qndkEfFr9FRcSisN6vdF9DTjCrRzWqV/QDz9sARgWt9wjFhOj8NQUdmghUS828NCQ9Ke X-Received: by 2002:a05:6402:145a:: with SMTP id d26mr27653913edx.182.1617015413710; Mon, 29 Mar 2021 03:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617015413; cv=none; d=google.com; s=arc-20160816; b=MxbXYyhtC1ZHQxUGG6CYLNWpmVKS1Qyx1zG6/JoKoRCMxgNmnL4ce+jvCpGZRBUmNV zGCfMqEjNICaN5FCB5lh76M6lbDPehvK/b29blt7pA0wIkj69BpGu0gGFcxNrk68rpPw MeBxd5D0dmetNs0nNU2U8W/DKeV2qHyy2Z3qH/ElEotQkBUyMbxy8dP/xGxly++mhYUg /Ck7JGtLVqJmmrqzBm9uZ1ITiLL/h5cRQQhPEiVG4Gp9tKgMxXcxAI4gQZaBYmEt7OJ8 TBudN8OURD2iWkMVSUSo7X+AmDJ3ZVsi6HdfO/3GjC2d+Dxc/rD0uMS9wKzFWFVkKxKG DiFA== 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=spo6TLpX/Lk6YOH3Lv3ELP6bg+fmwJHbqEmHIpnxzv4=; b=cueZqxWRwlMyufRauBioQwlkC3riJA6Z0rZOwoawsWM8hund+CPq3UTG00Ehzu2lvR Yf1u5N3zMZKD9JPCv/NYOuQvKUUZicODkZIMoZ5WD4Mi7fnNIcKhO0CcR94SMRc5NrA4 DdmIxR5zLnBN9yGPj655rvsi16TWqSIsW8jUm7pzO+yERiPVpUsEMzOvIWg4+hzH7/GQ GOv4HxvGoO3CfjOh76Q9JjoYCoAMaozHfys5c5HFEhD17tyrxqfZ8mxyN0irJHCgsZ+1 x7tQI0LjM3CRMUmpI1orJeo+ek4AUVR6OEHwvHhYGkiOB9mNNK1i+WIz6i1fl4E5RUq7 Muyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="T4/H3CWq"; 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 ko14si12259411ejc.419.2021.03.29.03.56.31; Mon, 29 Mar 2021 03:56:53 -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="T4/H3CWq"; 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 S233896AbhC2Ios (ORCPT + 99 others); Mon, 29 Mar 2021 04:44:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:42680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233922AbhC2I1f (ORCPT ); Mon, 29 Mar 2021 04:27:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3C774619BD; Mon, 29 Mar 2021 08:26:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006378; bh=mnOVFgj789hZ7bVE3o5Rqh7f6Og4rA1AlXhl6AygN8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T4/H3CWqOsKtLN/WWD08HapRo0ymb8+fu7qSn9mVVBnZsPIGF0qO2UfHDoZ574Unc sLCC46pq3p84pzxCYybHpk5JaWHAzmxmsCVlsOilmpSxxoagTcEL6Rs/rEuBI7XFec biXG0Vz6EMaWuikdrawG78mzTAXtgSoddbZ5pYQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Hancock , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 184/221] net: axienet: Fix probe error cleanup Date: Mon, 29 Mar 2021 09:58:35 +0200 Message-Id: <20210329075635.277569048@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@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: Robert Hancock [ Upstream commit 59cd4f19267a0aab87a8c07e4426eb7187ee548d ] The driver did not always clean up all allocated resources when probe failed. Fix the probe cleanup path to clean up everything that was allocated. Fixes: 57baf8cc70ea ("net: axienet: Handle deferred probe on clock properly") Signed-off-by: Robert Hancock Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/xilinx/xilinx_axienet_main.c | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 415676c2c11f..69c79cc24e6e 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1848,7 +1848,7 @@ static int axienet_probe(struct platform_device *pdev) if (IS_ERR(lp->regs)) { dev_err(&pdev->dev, "could not map Axi Ethernet regs.\n"); ret = PTR_ERR(lp->regs); - goto free_netdev; + goto cleanup_clk; } lp->regs_start = ethres->start; @@ -1923,12 +1923,12 @@ static int axienet_probe(struct platform_device *pdev) break; default: ret = -EINVAL; - goto free_netdev; + goto cleanup_clk; } } else { ret = of_get_phy_mode(pdev->dev.of_node, &lp->phy_mode); if (ret) - goto free_netdev; + goto cleanup_clk; } /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ @@ -1941,7 +1941,7 @@ static int axienet_probe(struct platform_device *pdev) dev_err(&pdev->dev, "unable to get DMA resource\n"); of_node_put(np); - goto free_netdev; + goto cleanup_clk; } lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares); @@ -1961,12 +1961,12 @@ static int axienet_probe(struct platform_device *pdev) if (IS_ERR(lp->dma_regs)) { dev_err(&pdev->dev, "could not map DMA regs\n"); ret = PTR_ERR(lp->dma_regs); - goto free_netdev; + goto cleanup_clk; } if ((lp->rx_irq <= 0) || (lp->tx_irq <= 0)) { dev_err(&pdev->dev, "could not determine irqs\n"); ret = -ENOMEM; - goto free_netdev; + goto cleanup_clk; } /* Autodetect the need for 64-bit DMA pointers. @@ -1996,7 +1996,7 @@ static int axienet_probe(struct platform_device *pdev) ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(addr_width)); if (ret) { dev_err(&pdev->dev, "No suitable DMA available\n"); - goto free_netdev; + goto cleanup_clk; } /* Check for Ethernet core IRQ (optional) */ @@ -2027,12 +2027,12 @@ static int axienet_probe(struct platform_device *pdev) if (!lp->phy_node) { dev_err(&pdev->dev, "phy-handle required for 1000BaseX/SGMII\n"); ret = -EINVAL; - goto free_netdev; + goto cleanup_mdio; } lp->pcs_phy = of_mdio_find_device(lp->phy_node); if (!lp->pcs_phy) { ret = -EPROBE_DEFER; - goto free_netdev; + goto cleanup_mdio; } lp->phylink_config.pcs_poll = true; } @@ -2046,17 +2046,30 @@ static int axienet_probe(struct platform_device *pdev) if (IS_ERR(lp->phylink)) { ret = PTR_ERR(lp->phylink); dev_err(&pdev->dev, "phylink_create error (%i)\n", ret); - goto free_netdev; + goto cleanup_mdio; } ret = register_netdev(lp->ndev); if (ret) { dev_err(lp->dev, "register_netdev() error (%i)\n", ret); - goto free_netdev; + goto cleanup_phylink; } return 0; +cleanup_phylink: + phylink_destroy(lp->phylink); + +cleanup_mdio: + if (lp->pcs_phy) + put_device(&lp->pcs_phy->dev); + if (lp->mii_bus) + axienet_mdio_teardown(lp); + of_node_put(lp->phy_node); + +cleanup_clk: + clk_disable_unprepare(lp->clk); + free_netdev: free_netdev(ndev); -- 2.30.1