Coverity has found some problems with the return paths in parts of this
code. We have a case where we were going to the wrong part of the
unwind (open() failed so we cannot close the fd), a case where we were
only free()ing our buf on the error path and finally a case where we did
not munmap in the failure path.
Reported-by: Coverity (CID: 138492, 138495, 143064)
Signed-off-by: Tom Rini <trini@konsulko.com>
if (fd < 0) {
fprintf(stderr, "%s: Can't open %s: %s\n",
params->cmdname, fname, strerror(errno));
- goto err;
+ goto err_buf;
}
ret = write(fd, buf, size);
if (ret != size) {
ret = -EIO;
goto err;
}
+ free(buf);
close(fd);
return 0;
ret = 0;
err:
+ munmap(old_fdt, sbuf.st_size);
free(fdt);
close(fd);
return ret;