Messages in this thread | | | Date | Mon, 20 Mar 2000 20:20:01 -0500 | From | Jeff Garzik <> | Subject | Re: [patch] 2.3.99-pre3-3: dev_alloc_name |
| |
Tim Waugh wrote: > > Part of the ether= problem is that the "eth%d" strings are all merged, and > get overwritten by dev_alloc_name. Here's the trivial fix for that.
This is not correct, Linus please don't apply.
Tim, take a look at drivers/net/net_init.c, init_etherdev and its call chain. dev->name is expected to be allocated by the caller, hence no need for the strdup. If dev->name is NOT valid somewhere down the line, the bug lies elsewhere...
Jeff
> > Tim. > */ > > --- linux/net/core/dev.c.orig Mon Mar 20 22:20:58 2000 > +++ linux/net/core/dev.c Mon Mar 20 22:25:14 2000 > @@ -343,6 +343,20 @@ > } > > /* > + * Yes, this really is implemented privately for the nth > + * time in the kernel. > + */ > + > +static char *strdup (const char *str) > +{ > + int n = strlen (str) + 1; > + char *s = kmalloc (n, GFP_KERNEL); > + if (s) > + strcpy (s, str); > + return s; > +} > + > +/* > * Passed a format string - eg "lt%d" it will try and find a suitable > * id. Not efficient for many devices, not called a lot.. > */ > @@ -358,7 +372,7 @@ > for (i = 0; i < 100; i++) { > sprintf(buf,name,i); > if (__dev_get_by_name(buf) == NULL) { > - strcpy(dev->name, buf); > + dev->name = strdup (buf); > return i; > } > } > > - > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.rutgers.edu > Please read the FAQ at http://www.tux.org/lkml/
-- Jeff Garzik | Tact is the ability to tell a man Building 1024 | he has an open mind when he has a MandrakeSoft, Inc. | hole in his head. (-random fortune)
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |