linux-next: build warning after merge of the driver-core tree
Subsystems (3)
Hi Greg,
After merging the driver-core tree, today's linux-next build (x86_64 allmodconfig) produced this warning:
drivers/net/dnet.c: In function 'dnet_mii_init':drivers/net/dnet.c:340: warning: passing argument 1 of 'platform_set_drvdata' from incompatible pointer type include/linux/platform_device.h:138: note: expected 'struct platform_device *' but argument is of type 'struct net_device *'
Revealed by commit 71d642908d4e8e7a2a4a6e0490432e719ff466d5 ("Driver
core: convert platform_{get,set}_drvdata to static inline functions"). Introduced by commit 4796417417a62e2ae83d92cb92e1ecf9ec67b5f5 ("dnet:
Dave DNET ethernet controller driver (updated)").
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
Quoted 5 lines · Stephen Rothwell
Hi Greg,
After merging the driver-core tree, today's linux-next build (
x86_64allmodconfig) produced this warning:
Quoted 8 lines
drivers/net/dnet.c: In function 'dnet_mii_init':drivers/net/dnet.c:340: warning: passing argument 1 of 'platform_set_drvdata' from incompatible pointer typeinclude/linux/platform_device.h:138: note: expected 'structplatform_device*' but argument is of type 'structnet_device*'Revealed by commit
71d642908d4e8e7a2a4a6e0490432e719ff466d5("Driver
core: convert platform_{get,set}_drvdata to static inline functions"). Introduced by commit4796417417a62e2ae83d92cb92e1ecf9ec67b5f5("dnet:
Dave DNET ethernet controller driver (updated)").
It sounds like the driver is wrong here :(
thanks,
greg k-h
Hi Stephen, Greg,
Quoted 6 lines · Stephen Rothwell
After merging the driver-core tree, today's linux-next build (
x86_64allmodconfig) produced this warning:
drivers/net/dnet.c: In function 'dnet_mii_init':drivers/net/dnet.c:340: warning: passing argument 1 of 'platform_set_drvdata' from incompatible pointer typeinclude/linux/platform_device.h:138: note: expected 'structplatform_device*' but argument is of type 'structnet_device*'
It's actually a bug in the driver. Thanks for reporting. I'll send the patch as a follow up.
Regards, Ilya.
PATCH 1/1 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.
--- drivers/net/dnet.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/dnet.c +1 -2
@@ -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;
@@ -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);
Signature · 1 line
1.7.4
Re: [PATCH] dnet: fix wrong use of platform_set_drvdata()
From: Ilya Yanok <[email protected]>
Date: Mon, 21 Feb 2011 21:20:30 +0100
Quoted 5 lines
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 <[email protected]>
Applied.