net: don't override ethernet address environment
authorRoger Quadros <rogerq@ti.com>
Mon, 13 Mar 2017 13:04:33 +0000 (15:04 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 20 Mar 2017 21:57:16 +0000 (17:57 -0400)
If the ethernet address environment is set with a valid
ethernet address prevent overriding it as it is most likely
set by the user and he/she doesn't want board code to
automatically override it whatsoever.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
net/eth_common.c

index e9d3c66741201f5ccfe321cf1431e3339f1ed18b..58fa295771020639ba8924d906787dc3f9d78430 100644 (file)
@@ -34,6 +34,9 @@ int eth_setenv_enetaddr(const char *name, const uchar *enetaddr)
 {
        char buf[ARP_HLEN_ASCII + 1];
 
+       if (eth_getenv_enetaddr(name, (uchar *)buf))
+               return -EEXIST;
+
        sprintf(buf, "%pM", enetaddr);
 
        return setenv(name, buf);