korina: fix probing crash
Subsystems (3)
PATCH 1/1 korina: fix probing crash
From: Florian Fainelli <[email protected]>
Subject: [PATCH] korina: fix probing crash
This patch fixes the wrong retrieval of platform_data which makes the driver crash on probe. Propagate error if the platform_driver cannot use its data.
---
drivers/net/korina.c +7 -1
@@ -1078,12 +1078,18 @@ static int korina_close(struct net_device *dev)static int korina_probe (struct platform_device *pdev) { -struct korina_device *bif =platform_get_drvdata (pdev); +struct korina_device *bif;struct korina_private *lp;struct net_device *dev;struct resource *r;int rc; + bif = (struct korina_device *)pdev->dev.platform_data; +if (!bif) { + printk(KERN_ERR DRV_NAME ": missing platform data\n"); +return -ENODEV ; + } + dev =alloc_etherdev (sizeof (struct korina_private ));if (!dev) { printk(KERN_ERR DRV_NAME ": alloc_etherdev failed\n");
David Miller
maintainerFrom: Florian Fainelli <[email protected]>
Date: Sun, 11 Jan 2009 16:54:24 +0100
Quoted 7 lines
korina: fix probing crash
This patch fixes the wrong retrieval of
platform_datawhich makes the driver crash on probe. Propagate error if theplatform_drivercannot use its data.Signed-off-by Florian Fainelli <[email protected]>
There are several problems with this patch:
drivers/net/korina.c static int korina_close(struct net_device *dev) · line 1087
Quoted 12 lines
drivers/net/korina.c +2
-1@@ -1078,12 +1078,18 @@ static int korina_close(struct net_device *dev)static int korina_probe (struct platform_device *pdev) { -struct korina_device *bif =platform_get_drvdata (pdev); +struct korina_device *bif;struct korina_private *lp;struct net_device *dev;struct resource *r;int rc; + bif = (struct korina_device *)pdev->dev.platform_data;
This cast is unnecessary, platform_data is "void *"
Secondly, korina_remove() also expects the korina_device pointer to be in the platform drvdata. It therefore has the same bug as korina_probe() and needs to be fixed too.
But I suspect there is some other weird problem here. If you need to change from drvdata over to platform_data, then this driver never could have been probed or removed properly.
This is absolutely a fundamental bug, where did it come from?
A message that is not in the archive (sent off-list or not yet received): [email protected]
Florian Fainelli
Acked-byRe: [PATCH] MIPS: rb532: use driver_data instead of platform_data
Le Wednesday 14 January 2009 18:41:14 Phil Sutter, vous avez écrit :
Quoted 3 lines
As the korina ethernet driver uses
platform_get_drvdata()to extract the driver specific data from the platform device,driver_datahas to be used here.
Right, thanks for changing this.
Quoted 2 lines
Signed-off-by Phil Sutter <[email protected]>
Signature · 4 lines
Best regards, Florian Fainelli Email : [email protected] http://openwrt.org -------------------------------
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH] korina: fix usage of driver_data
From: Phil Sutter <[email protected]>
Date: Wed, 14 Jan 2009 18:47:21 +0100
Quoted 6 lines
Using
platform_set_drvdata()here makes no sense, since thedriver_datafield has already been filled with valuable data (i.e. the MAC address). Also havingdriver_datapoint to thenet_deviceis rather pointless since structkorina_devicecontains an apropriate field for it.Signed-off-by Phil Sutter <[email protected]>
Applied.
PATCH 1/1 MIPS: rb532: use driver_data instead of platform_data
In reply to David MillerAs the korina ethernet driver uses platform_get_drvdata() to extract the driver specific data from the platform device, driver_data has to be used here.
--- arch/mips/rb532/devices.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/mips/rb532/devices.c +1 -1
@@ -89,7 +89,7 @@ static struct korina_device korina_dev0_data = {static struct platform_device korina_dev0 = { .id =-1 , .name ="korina" , - .dev.platform_data = &korina_dev0_data, + .dev.driver_data = &korina_dev0_data, .resource = korina_dev0_res, .num_resources =ARRAY_SIZE (korina_dev0_res), };
Signature · 1 line
1.5.6.4
Ralf Baechle
AppliedRe: [PATCH] MIPS: rb532: use driver_data instead of platform_data
On Thu, Jan 15, 2009 at 03:41:44PM +0100, Phil Sutter wrote:
Applied. Thanks,
Ralf