Commit 02e1d3eb authored by Andrew Morton's avatar Andrew Morton Committed by Jeff Garzik

[PATCH] M68k HP Lance Ethernet: Fix leaks on probe/removal

From: Geert Uytterhoeven <geert@linux-m68k.org>

HP Lance Ethernet: There's tons of leaks in the hplcance probing code, and it
doesn't release the memory region on removal either (from Christoph Hellwig)
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent b6691d79
...@@ -76,25 +76,31 @@ static int __devinit hplance_init_one(struct dio_dev *d, ...@@ -76,25 +76,31 @@ static int __devinit hplance_init_one(struct dio_dev *d,
const struct dio_device_id *ent) const struct dio_device_id *ent)
{ {
struct net_device *dev; struct net_device *dev;
int err; int err = -ENOMEM;
dev = alloc_etherdev(sizeof(struct hplance_private)); dev = alloc_etherdev(sizeof(struct hplance_private));
if (!dev) if (!dev)
return -ENOMEM; goto out;
if (!request_mem_region(d->resource.start, d->resource.end-d->resource.start, d->name)) err = -EBUSY;
return -EBUSY; if (!request_mem_region(dio_resource_start(d),
dio_resource_len(d), d->name))
SET_MODULE_OWNER(dev); goto out_free_netdev;
hplance_init(dev, d); hplance_init(dev, d);
err = register_netdev(dev); err = register_netdev(dev);
if (err) { if (err)
free_netdev(dev); goto out_release_mem_region;
return err;
}
dio_set_drvdata(d, dev); dio_set_drvdata(d, dev);
return 0; return 0;
out_release_mem_region:
release_mem_region(dio_resource_start(d), dio_resource_len(d));
out_free_netdev:
free_netdev(dev);
out:
return err;
} }
static void __devexit hplance_remove_one(struct dio_dev *d) static void __devexit hplance_remove_one(struct dio_dev *d)
...@@ -102,6 +108,7 @@ static void __devexit hplance_remove_one(struct dio_dev *d) ...@@ -102,6 +108,7 @@ static void __devexit hplance_remove_one(struct dio_dev *d)
struct net_device *dev = dio_get_drvdata(d); struct net_device *dev = dio_get_drvdata(d);
unregister_netdev(dev); unregister_netdev(dev);
release_mem_region(dio_resource_start(d), dio_resource_len(d));
free_netdev(dev); free_netdev(dev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment