Skip to content

Commit

Permalink
dnet: fix wrong use of platform_set_drvdata()
Browse files Browse the repository at this point in the history
platform_set_drvdata() was used with argument of incorrect type and
could cause memory corruption. Moreover, because of not setting drvdata
in the correct place not all resources were freed upon module unload.

Signed-off-by: Ilya Yanok <yanok@emcraft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ilya Yanok authored and David S. Miller committed Feb 28, 2011
1 parent 9152394 commit b093dd9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/net/dnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,6 @@ static int dnet_mii_init(struct dnet *bp)
for (i = 0; i < PHY_MAX_ADDR; i++)
bp->mii_bus->irq[i] = PHY_POLL;

platform_set_drvdata(bp->dev, bp->mii_bus);

if (mdiobus_register(bp->mii_bus)) {
err = -ENXIO;
goto err_out_free_mdio_irq;
Expand Down Expand Up @@ -863,6 +861,7 @@ static int __devinit dnet_probe(struct platform_device *pdev)
bp = netdev_priv(dev);
bp->dev = dev;

platform_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev);

spin_lock_init(&bp->lock);
Expand Down

0 comments on commit b093dd9

Please sign in to comment.