Commit b093dd96844186cd03318aaf0cd96f91db3970ef

Authored by Ilya Yanok
Committed by David S. Miller
1 parent 915239472a

dnet: fix wrong use of platform_set_drvdata()

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>

Showing 1 changed file with 1 additions and 2 deletions Side-by-side Diff

... ... @@ -337,8 +337,6 @@
337 337 for (i = 0; i < PHY_MAX_ADDR; i++)
338 338 bp->mii_bus->irq[i] = PHY_POLL;
339 339  
340   - platform_set_drvdata(bp->dev, bp->mii_bus);
341   -
342 340 if (mdiobus_register(bp->mii_bus)) {
343 341 err = -ENXIO;
344 342 goto err_out_free_mdio_irq;
... ... @@ -863,6 +861,7 @@
863 861 bp = netdev_priv(dev);
864 862 bp->dev = dev;
865 863  
  864 + platform_set_drvdata(pdev, dev);
866 865 SET_NETDEV_DEV(dev, &pdev->dev);
867 866  
868 867 spin_lock_init(&bp->lock);