Module Name:    src
Committed By:   jmcneill
Date:           Mon Nov 10 20:36:12 UTC 2014

Modified Files:
        src/sys/arch/evbarm/awin: awin_machdep.c

Log Message:
get_bootconf_option doesnt return the value null-terminated, so look for an 
awge0.mac-address value of exactly the correct length


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/evbarm/awin/awin_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/awin/awin_machdep.c
diff -u src/sys/arch/evbarm/awin/awin_machdep.c:1.26 src/sys/arch/evbarm/awin/awin_machdep.c:1.27
--- src/sys/arch/evbarm/awin/awin_machdep.c:1.26	Mon Nov 10 17:56:08 2014
+++ src/sys/arch/evbarm/awin/awin_machdep.c	Mon Nov 10 20:36:12 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: awin_machdep.c,v 1.26 2014/11/10 17:56:08 jmcneill Exp $ */
+/*	$NetBSD: awin_machdep.c,v 1.27 2014/11/10 20:36:12 jmcneill Exp $ */
 
 /*
  * Machine dependent functions for kernel setup for TI OSK5912 board.
@@ -125,7 +125,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_machdep.c,v 1.26 2014/11/10 17:56:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_machdep.c,v 1.27 2014/11/10 20:36:12 jmcneill Exp $");
 
 #include "opt_machdep.h"
 #include "opt_ddb.h"
@@ -725,14 +725,18 @@ awin_device_register(device_t self, void
 		char *mac_addr;
 		snprintf(argname, sizeof(argname), "%s.mac-address",
 		    device_xname(self));
+
 		if (get_bootconf_option(boot_args, argname,
-		    BOOTOPT_TYPE_STRING, &mac_addr) &&
-		    ether_aton_r(enaddr, sizeof(enaddr), mac_addr) == 0) {
-			prop_data_t pd;
-			pd = prop_data_create_data(enaddr, sizeof(enaddr));
-			KASSERT(pd != NULL);
-			prop_dictionary_set(dict, "mac-address", pd);
-			prop_object_release(pd);
+		    BOOTOPT_TYPE_STRING, &mac_addr)) {
+			char mac[strlen("XX:XX:XX:XX:XX:XX") + 1];
+			strlcpy(mac, mac_addr, sizeof(mac));
+			if (!ether_aton_r(enaddr, sizeof(enaddr), mac)) {
+				prop_data_t pd;
+				pd = prop_data_create_data(enaddr, sizeof(enaddr));
+				KASSERT(pd != NULL);
+				prop_dictionary_set(dict, "mac-address", pd);
+				prop_object_release(pd);
+			}
 		}
 
 #if AWIN_board == AWIN_cubieboard

Reply via email to