From patchwork Mon Nov 28 18:24:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9450003 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AFC2860757 for ; Mon, 28 Nov 2016 18:33:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5D1A25D97 for ; Mon, 28 Nov 2016 18:33:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A15E27F8D; Mon, 28 Nov 2016 18:33:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5102827F8D for ; Mon, 28 Nov 2016 18:33:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754606AbcK1SdI (ORCPT ); Mon, 28 Nov 2016 13:33:08 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:36312 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751479AbcK1S1a (ORCPT ); Mon, 28 Nov 2016 13:27:30 -0500 Received: by mail-lf0-f67.google.com with SMTP id o20so10330284lfg.3; Mon, 28 Nov 2016 10:27:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=st2qrAWEhLbIRtndc6L8lJV56/124tZlxSNSXl+j9TA=; b=auvp92LofbtANNCiohmNzKUa4zp3E/c6XJUm+AjEpY4UwQBWBRYirMgeCaZ8KW0cts vl9vi9C9iopzL8+V0xHF70pxt3kpS88e36dVqmBbP4PuChTRPhMwpPZUq/rxtPIikMBG DWhwesmu0/5VJO6ZFqisDjR0GimFf/icKS5YerIe6zK+07KVgP3ddYJ9y686tnvn93Gn /zBvpg/4sUDJeOBBKLkxiahWoM3HrWrJKwREMv4014bEnrKSY66tDPHJCEN2iTqmBReK GmqzmxnfWojYePP7uraBJbQIkdkIHPaBPcXDZ7IbUQ+Eb/QCaHB5fxsDCXIGI/P8I5zJ WjkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=st2qrAWEhLbIRtndc6L8lJV56/124tZlxSNSXl+j9TA=; b=ml6E/3vv8Rz677RC63lo1eDI07l8pj90nsrAJHGiapq7sJUwP68MOsVJsl7WHg2VoO emorQZeANexvrWzGwkuxV/V7dyCoeJTLEOIMX+6gs7LZJ5kZaITiubsgqvBuJ5RJWhs4 nqyq5+2ZGi7LI7M7xkEqxO5Z535dfos8ftsiLnV/ByS1yGP4wK0KwkxFzhSiAYKWpS6Y 5TrOcltlJwGDXicN35SiSHAFwj54YZ5Y7ZzsBAmqCnSOiAa+v+8PH8mIJApcMlW9xbEM 23dzSa4vK0Hz7+fti2bqaTJORTtMFX5Pbz7XItPYG3sIZ8/mydyxUkrciv3EKEU2G4dh A6Tg== X-Gm-Message-State: AKaTC01qLzPg4TDQX+CTVs+r3bA1zkHqIQz7NCEyj8R2QlxJPI08K/8Klw1IC6WRwP8hsA== X-Received: by 10.25.25.71 with SMTP id 68mr8829626lfz.9.1480357648401; Mon, 28 Nov 2016 10:27:28 -0800 (PST) Received: from xi.terra (c-04aadb54.07-184-6d6c6d4.cust.bredbandsbolaget.se. [84.219.170.4]) by smtp.gmail.com with ESMTPSA id 196sm12986089lff.3.2016.11.28.10.27.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 10:27:26 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.87) (envelope-from ) id 1cBQeA-0007KK-7u; Mon, 28 Nov 2016 19:27:22 +0100 From: Johan Hovold To: "David S. Miller" Cc: Vince Bridgers , Florian Fainelli , Fugang Duan , Pantelis Antoniou , Vitaly Bordug , Claudiu Manoil , Li Yang , Thomas Petazzoni , Felix Fietkau , John Crispin , Matthias Brugger , Sergei Shtylyov , Lars Persson , Mugunthan V N , Grygorii Strashko , Rob Herring , Frank Rowand , Andrew Lunn , Vivien Didelot , netdev@vger.kernel.org, nios2-dev@lists.rocketboards.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-omap@vger.kernel.org, devicetree@vger.kernel.org, Johan Hovold Subject: [PATCH net 05/16] net: ethernet: bcmsysport: fix fixed-link phydev leaks Date: Mon, 28 Nov 2016 19:24:58 +0100 Message-Id: <1480357509-28074-6-git-send-email-johan@kernel.org> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1480357509-28074-1-git-send-email-johan@kernel.org> References: <1480357509-28074-1-git-send-email-johan@kernel.org> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure to deregister and free any fixed-link PHY registered using of_phy_register_fixed_link() on probe errors and on driver unbind. Fixes: 186534a3f832 ("net: systemport: use the new fixed PHY helpers") Signed-off-by: Johan Hovold --- drivers/net/ethernet/broadcom/bcmsysport.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index c3354b9941d1..25d1eb4933d0 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -1755,13 +1755,13 @@ static int bcm_sysport_probe(struct platform_device *pdev) if (priv->irq0 <= 0 || priv->irq1 <= 0) { dev_err(&pdev->dev, "invalid interrupts\n"); ret = -EINVAL; - goto err; + goto err_free_netdev; } priv->base = devm_ioremap_resource(&pdev->dev, r); if (IS_ERR(priv->base)) { ret = PTR_ERR(priv->base); - goto err; + goto err_free_netdev; } priv->netdev = dev; @@ -1779,7 +1779,7 @@ static int bcm_sysport_probe(struct platform_device *pdev) ret = of_phy_register_fixed_link(dn); if (ret) { dev_err(&pdev->dev, "failed to register fixed PHY\n"); - goto err; + goto err_free_netdev; } priv->phy_dn = dn; @@ -1821,7 +1821,7 @@ static int bcm_sysport_probe(struct platform_device *pdev) ret = register_netdev(dev); if (ret) { dev_err(&pdev->dev, "failed to register net_device\n"); - goto err; + goto err_deregister_fixed_link; } priv->rev = topctrl_readl(priv, REV_CNTL) & REV_MASK; @@ -1832,7 +1832,11 @@ static int bcm_sysport_probe(struct platform_device *pdev) priv->base, priv->irq0, priv->irq1, txq, rxq); return 0; -err: + +err_deregister_fixed_link: + if (of_phy_is_fixed_link(dn)) + of_phy_deregister_fixed_link(dn); +err_free_netdev: free_netdev(dev); return ret; } @@ -1840,11 +1844,14 @@ static int bcm_sysport_probe(struct platform_device *pdev) static int bcm_sysport_remove(struct platform_device *pdev) { struct net_device *dev = dev_get_drvdata(&pdev->dev); + struct device_node *dn = pdev->dev.of_node; /* Not much to do, ndo_close has been called * and we use managed allocations */ unregister_netdev(dev); + if (of_phy_is_fixed_link(dn)) + of_phy_deregister_fixed_link(dn); free_netdev(dev); dev_set_drvdata(&pdev->dev, NULL);