]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
ac14xx: fix a potential NULL deref in diagnostics
authorGerhard Sittig <gsi@denx.de>
Wed, 5 Jun 2013 12:51:05 +0000 (14:51 +0200)
committerWolfgang Denk <wd@denx.de>
Mon, 24 Jun 2013 20:24:29 +0000 (22:24 +0200)
getenv() immediately after setenv() may perfectly legally return NULL, so
make sure to not deference an invalid pointer when creating diagnostic output

Signed-off-by: Gerhard Sittig <gsi@denx.de>
board/ifm/ac14xx/ac14xx.c

index 74425912d62ffd55a1c9cdc347eef7b78a2dd28a..f200b45f10f5b2eb6b331fff6f72482bd0eb0057 100644 (file)
@@ -209,6 +209,7 @@ static int read_eeprom(void)
 int mac_read_from_eeprom(void)
 {
        const u8 *mac;
+       const char *mac_txt;
 
        if (read_eeprom()) {
                printf("I2C EEPROM read failed.\n");
@@ -230,8 +231,11 @@ int mac_read_from_eeprom(void)
 
        if (mac && is_valid_ether_addr(mac)) {
                eth_setenv_enetaddr("ethaddr", mac);
-               printf("DIAG: %s() MAC value [%s]\n",
-                       __func__, getenv("ethaddr"));
+               mac_txt = getenv("ethaddr");
+               if (mac_txt)
+                       printf("DIAG: MAC value [%s]\n", mac_txt);
+               else
+                       printf("DIAG: failed to setup MAC env\n");
        }
 
        return 0;