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,
const struct dio_device_id *ent)
{
struct net_device *dev;
int err;
int err = -ENOMEM;
dev = alloc_etherdev(sizeof(struct hplance_private));
if (!dev)
return -ENOMEM;
goto out;
if (!request_mem_region(d->resource.start, d->resource.end-d->resource.start, d->name))
return -EBUSY;
err = -EBUSY;
if (!request_mem_region(dio_resource_start(d),
dio_resource_len(d), d->name))
goto out_free_netdev;
SET_MODULE_OWNER(dev);
hplance_init(dev, d);
err = register_netdev(dev);
if (err) {
free_netdev(dev);
return err;
}
if (err)
goto out_release_mem_region;
dio_set_drvdata(d, dev);
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)
......@@ -102,6 +108,7 @@ static void __devexit hplance_remove_one(struct dio_dev *d)
struct net_device *dev = dio_get_drvdata(d);
unregister_netdev(dev);
release_mem_region(dio_resource_start(d), dio_resource_len(d));
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