Message ID | 1346341819-20125-1-git-send-email-srinivas.kandagatla@st.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
From: Srinivas KANDAGATLA <srinivas.kandagatla@st.com> Date: Thu, 30 Aug 2012 16:50:19 +0100 > From: Srinivas Kandagatla <srinivas.kandagatla@st.com> > > This patch fixes stmmac_pltfr_remove function, which is broken because, > it is accessing plat variable via freed memory priv pointer which gets > freed by free_netdev called from stmmac_dvr_remove. > > In short this patch caches the plat pointer in local variable before > calling stmmac_dvr_remove to prevent code accessing freed memory. > > Without this patch any attempt to remove the stmmac device will fail as > below: ... > Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com> Applied. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index b93245c..b4ffdc7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -186,6 +186,7 @@ static int stmmac_pltfr_remove(struct platform_device *pdev) { struct net_device *ndev = platform_get_drvdata(pdev); struct stmmac_priv *priv = netdev_priv(ndev); + void __iomem *addr = priv->ioaddr; struct resource *res; int ret = stmmac_dvr_remove(ndev); @@ -194,7 +195,7 @@ static int stmmac_pltfr_remove(struct platform_device *pdev) platform_set_drvdata(pdev, NULL); - iounmap((void __force __iomem *)priv->ioaddr); + iounmap(addr); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); release_mem_region(res->start, resource_size(res));