netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bryan O'Donoghue <pure.logic@nexus-software.ie>
To: peppe.cavallaro@st.com, netdev@vger.kernel.org, davem@davemloft.net
Cc: andriy.shevchenko@linux.intel.com, hock.leong.kweh@intel.com,
	boon.leong.ong@intel.com, dan.odonovan@emutex.com,
	linux-kernel@vger.kernel.org,
	Bryan O'Donoghue <pure.logic@nexus-software.ie>
Subject: [PATCH 1/1] stmmac: bugfix oops on rmmod after ifconfig
Date: Mon, 13 Apr 2015 12:15:13 +0100	[thread overview]
Message-ID: <1428923713-2419-2-git-send-email-pure.logic@nexus-software.ie> (raw)
In-Reply-To: <1428923713-2419-1-git-send-email-pure.logic@nexus-software.ie>

An oops exists in the flow of stmmac_release().
phy_ethtool_get_wol() depends on phydev->drv which will be null in
stmmac_dvr_remove after stmmac_mdio_unreg() completes.

Steps to reproduce on Quark X1000:

1. ifconfig eth0 192.168.0.1
2. rmmod stmmac_pci

This patch re-orders the calling of the unreg() functions so that
stmmac_unreg_mdio() happens later in the release() routine thus avoiding the
null pointer dereference.

Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Reported-by: Dan O'Donovan <dan.odonovan@emutex.com>

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a0ea84f..3ab3e4a8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2958,14 +2958,14 @@ int stmmac_dvr_remove(struct net_device *ndev)
 	priv->hw->dma->stop_tx(priv->ioaddr);
 
 	stmmac_set_mac(priv->ioaddr, false);
-	if (priv->pcs != STMMAC_PCS_RGMII && priv->pcs != STMMAC_PCS_TBI &&
-	    priv->pcs != STMMAC_PCS_RTBI)
-		stmmac_mdio_unregister(ndev);
 	netif_carrier_off(ndev);
 	unregister_netdev(ndev);
 	if (priv->stmmac_rst)
 		reset_control_assert(priv->stmmac_rst);
 	clk_disable_unprepare(priv->stmmac_clk);
+	if (priv->pcs != STMMAC_PCS_RGMII && priv->pcs != STMMAC_PCS_TBI &&
+	    priv->pcs != STMMAC_PCS_RTBI)
+		stmmac_mdio_unregister(ndev);
 	free_netdev(ndev);
 
 	return 0;
-- 
1.9.1

  reply	other threads:[~2015-04-13 11:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-13 11:15 [PATCH 0/1] stmmac: rmmod oops after ifconfig on interface Bryan O'Donoghue
2015-04-13 11:15 ` Bryan O'Donoghue [this message]
2015-04-13 11:35   ` [PATCH 1/1] stmmac: bugfix oops on rmmod after ifconfig Andy Shevchenko
2015-04-13 11:34 ` [PATCH 0/1] stmmac: rmmod oops after ifconfig on interface Andy Shevchenko
2015-04-13 12:29   ` Bryan O'Donoghue
     [not found]     ` <552BC36F.3060809@nexus-software.ie>
2015-04-13 13:33       ` Andy Shevchenko
2015-04-14 18:13         ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428923713-2419-2-git-send-email-pure.logic@nexus-software.ie \
    --to=pure.logic@nexus-software.ie \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=boon.leong.ong@intel.com \
    --cc=dan.odonovan@emutex.com \
    --cc=davem@davemloft.net \
    --cc=hock.leong.kweh@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).