]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - tools/ifdtool.c
tools: ifdtool: Do not write region while its size is negative
[karo-tx-uboot.git] / tools / ifdtool.c
index fe8366ba4f6fb16a871676356817e4bcb75862c2..1d61df19f231016f0eee82d275bf47c63e258215 100644 (file)
@@ -462,7 +462,7 @@ static int write_regions(char *image, int size)
                if (ret)
                        return ret;
                dump_region(i, frba);
-               if (region.size == 0)
+               if (region.size <= 0)
                        continue;
                region_fd = open(region_filename(i),
                                 O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR |
@@ -788,9 +788,9 @@ static int write_uboot(char *image, int size, struct input_file *uboot,
                              fdt_strerror(data_size));
                        return -ENOENT;
                }
-               offset = ucode_ptr - uboot->addr;
+               offset = (uint32_t)(ucode_ptr + size);
                ptr = (void *)image + offset;
-               ptr[0] = uboot->addr + (data - image);
+               ptr[0] = (data - image) - size;
                ptr[1] = data_size;
                debug("Wrote microcode pointer at %x: addr=%x, size=%x\n",
                      ucode_ptr, ptr[0], ptr[1]);