env: Move env_set() to env.h
[oweals/u-boot.git] / tools / env / fw_env.c
index a5d75958e1b65970ac5c8a486cab045959a3fdce..f06252d9168af09a6e31e48f59570e3380c36f22 100644 (file)
@@ -10,6 +10,7 @@
 #define _GNU_SOURCE
 
 #include <compiler.h>
+#include <env.h>
 #include <errno.h>
 #include <env_flags.h>
 #include <fcntl.h>
@@ -1317,7 +1318,7 @@ static int flash_io_write(int fd_current)
                        rc = -1;
                }
 
-               if (target_temp) {
+               if (rc >= 0 && target_temp) {
                        int dir_fd;
 
                        dir_fd = open(dname, O_DIRECTORY | O_RDONLY);
@@ -1566,7 +1567,7 @@ int fw_env_open(struct env_opts *opts)
                free(addr0);
 
        if (addr1)
-               free(addr0);
+               free(addr1);
 
        return ret;
 }
@@ -1742,7 +1743,7 @@ static int parse_config(struct env_opts *opts)
 
                if (ENVSIZE(0) != ENVSIZE(1)) {
                        fprintf(stderr,
-                               "Redundant environments have unequal size");
+                               "Redundant environments have unequal size\n");
                        return -1;
                }
        }