aboutsummaryrefslogtreecommitdiffstats
path: root/package/switch/src
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2011-02-20 17:24:15 +0000
committerFlorian Fainelli <florian@openwrt.org>2011-02-20 17:24:15 +0000
commit640927dde360260688f30083433b0d88a151dbed (patch)
tree2de8dd410b20e30d495acd5babcb2bb5aa15b0d4 /package/switch/src
parent650566c9806bf5b22d6667c142d9a87b4881438c (diff)
downloadupstream-640927dde360260688f30083433b0d88a151dbed.tar.gz
upstream-640927dde360260688f30083433b0d88a151dbed.tar.bz2
upstream-640927dde360260688f30083433b0d88a151dbed.zip
switch: fix switch-robo device reference counting
Fix incorrect device reference counting by switch-robo. Signed-off-by: George Kashperko <george@znau.edu.ua> SVN-Revision: 25619
Diffstat (limited to 'package/switch/src')
-rw-r--r--package/switch/src/switch-robo.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/package/switch/src/switch-robo.c b/package/switch/src/switch-robo.c
index 2fca360578..817fba3f48 100644
--- a/package/switch/src/switch-robo.c
+++ b/package/switch/src/switch-robo.c
@@ -301,7 +301,7 @@ static int robo_probe(char *devname)
{
__u32 phyid;
unsigned int i;
- int err;
+ int err = 1;
printk(KERN_INFO PFX "Probing device %s: ", devname);
strcpy(robo.ifr.ifr_name, devname);
@@ -331,7 +331,7 @@ static int robo_probe(char *devname)
(mii->phy_id != ROBO_PHY_ADDR_BCM63XX) &&
(mii->phy_id != ROBO_PHY_ADDR_TG3)) {
printk("Invalid phy address (%d)\n", mii->phy_id);
- return 1;
+ goto done;
}
robo.use_et = 0;
/* The robo has a fixed PHY address that is different from the
@@ -344,7 +344,7 @@ static int robo_probe(char *devname)
if (phyid == 0xffffffff || phyid == 0x55210022) {
printk("No Robo switch in managed mode found, phy_id = 0x%08x\n", phyid);
- return 1;
+ goto done;
}
/* Get the device ID */
@@ -361,11 +361,18 @@ static int robo_probe(char *devname)
robo_switch_reset();
err = robo_switch_enable();
if (err)
- return err;
+ goto done;
+ err = 0;
printk("found a 5%s%x!%s\n", robo.devid & 0xff00 ? "" : "3", robo.devid,
robo.is_5350 ? " It's a 5350." : "");
- return 0;
+
+done:
+ if (err) {
+ dev_put(robo.dev);
+ robo.dev = NULL;
+ }
+ return err;
}
@@ -610,6 +617,8 @@ static int __init robo_init(void)
static void __exit robo_exit(void)
{
switch_unregister_driver(DRIVER_NAME);
+ if (robo.dev)
+ dev_put(robo.dev);
kfree(robo.device);
}