Commit 0582b7d1 authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by David S. Miller

sh_eth: fix bitbang memory leak

sh_mdio_init() allocates pointer to 'struct bb_info' but only stores it locally,
so that sh_mdio_release() can't free it on driver unload.  Add the pointer to
'struct bb_info' to 'struct sh_eth_private', so that sh_mdio_init() can save
'bitbang' variable for sh_mdio_release() to be able to free it later...
Signed-off-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 283951f9
...@@ -2220,6 +2220,7 @@ static void sh_eth_tsu_init(struct sh_eth_private *mdp) ...@@ -2220,6 +2220,7 @@ static void sh_eth_tsu_init(struct sh_eth_private *mdp)
/* MDIO bus release function */ /* MDIO bus release function */
static int sh_mdio_release(struct net_device *ndev) static int sh_mdio_release(struct net_device *ndev)
{ {
struct sh_eth_private *mdp = netdev_priv(ndev);
struct mii_bus *bus = dev_get_drvdata(&ndev->dev); struct mii_bus *bus = dev_get_drvdata(&ndev->dev);
/* unregister mdio bus */ /* unregister mdio bus */
...@@ -2234,6 +2235,9 @@ static int sh_mdio_release(struct net_device *ndev) ...@@ -2234,6 +2235,9 @@ static int sh_mdio_release(struct net_device *ndev)
/* free bitbang info */ /* free bitbang info */
free_mdio_bitbang(bus); free_mdio_bitbang(bus);
/* free bitbang memory */
kfree(mdp->bitbang);
return 0; return 0;
} }
...@@ -2262,6 +2266,7 @@ static int sh_mdio_init(struct net_device *ndev, int id, ...@@ -2262,6 +2266,7 @@ static int sh_mdio_init(struct net_device *ndev, int id,
bitbang->ctrl.ops = &bb_ops; bitbang->ctrl.ops = &bb_ops;
/* MII controller setting */ /* MII controller setting */
mdp->bitbang = bitbang;
mdp->mii_bus = alloc_mdio_bitbang(&bitbang->ctrl); mdp->mii_bus = alloc_mdio_bitbang(&bitbang->ctrl);
if (!mdp->mii_bus) { if (!mdp->mii_bus) {
ret = -ENOMEM; ret = -ENOMEM;
......
...@@ -705,6 +705,7 @@ struct sh_eth_private { ...@@ -705,6 +705,7 @@ struct sh_eth_private {
const u16 *reg_offset; const u16 *reg_offset;
void __iomem *addr; void __iomem *addr;
void __iomem *tsu_addr; void __iomem *tsu_addr;
struct bb_info *bitbang;
u32 num_rx_ring; u32 num_rx_ring;
u32 num_tx_ring; u32 num_tx_ring;
dma_addr_t rx_desc_dma; dma_addr_t rx_desc_dma;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment