Re: [PATCH 475] HP300 LANCE

From: Christoph Hellwig
Date: Tue Nov 16 2004 - 03:45:34 EST


On Mon, Nov 01, 2004 at 02:22:45PM +0000, Christoph Hellwig wrote:
> On Sun, Oct 31, 2004 at 11:03:30AM +0100, Geert Uytterhoeven wrote:
> > HP300 LANCE updates from Kars de Jong:
> > - Updated HP LANCE driver to use the new DIO semantics
> > - If only HP LANCE or MVME147 LANCE is selected, enable compile-time
> > choice of LANCE register access. If both are defined, go through the
> > function pointer
> > - Added support for CONFIG_NET_POLL_CONTROLLER
> > - Fixed problem with disabling board interrupts in hplance_close() which
> > caused the driver to lock up
>
> There's tons of leaks in the hplcance probing code, and it doesn't release
> he memory region on removal either.
>
> Untested patch to fix those issues below:

ping.

--- 1.12/drivers/net/hplance.c 2004-10-06 22:44:40 +02:00
+++ edited/drivers/net/hplance.c 2004-11-01 10:20:17 +01:00
@@ -71,30 +71,42 @@
.remove = __devexit_p(hplance_remove_one),
};

+/* XXX(hch): should probably move to a better place */
+#define dio_resource_start(d) \
+ ((d)->resource.start)
+#define dio_resource_len(d) \
+ ((d)->resource.end - (d)->resource.start)
+
/* Find all the HP Lance boards and initialise them... */
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_free_netdev;
+
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 +114,7 @@
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);
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/