[patch] 2.3.99-pre3-3: dev_alloc_name

From: Tim Waugh (tim@cyberelk.demon.co.uk)
Date: Mon Mar 20 2000 - 17:26:49 EST


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.

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/



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