Re: [patch] 2.3.99-pre3-3: dev_alloc_name

From: Jeff Garzik (jgarzik@mandrakesoft.com)
Date: Mon Mar 20 2000 - 20:20:01 EST


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/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:31 EST