Plug leaks

Reported by:	Coverity
CID:		1340155 and 1340156
MFC after:	1 week
This commit is contained in:
Baptiste Daroussin 2016-04-20 21:11:49 +00:00
parent 29bda43fa4
commit 4ecb514126

View File

@ -83,6 +83,7 @@ flash_save(int argc, char **argv)
if ((size = mps_firmware_get(fd, &firmware_buffer, bios)) < 0) {
warnx("Fail to save %s", argv[1]);
close(fd);
return (1);
}
@ -100,6 +101,7 @@ flash_save(int argc, char **argv)
error = errno;
warn("write");
free(firmware_buffer);
close(fd);
return (error);
}
written += ret;
@ -189,12 +191,14 @@ flash_update(int argc, char **argv)
warnx("Invalid bios: no boot record magic number");
munmap(mem, st.st_size);
close(fd);
free(facts);
return (1);
}
if ((st.st_size % 512) != 0) {
warnx("Invalid bios: size not a multiple of 512");
munmap(mem, st.st_size);
close(fd);
free(facts);
return (1);
}
} else {
@ -206,6 +210,7 @@ flash_update(int argc, char **argv)
warnx(" Image Vendor ID: %04x", fwheader->VendorID);
munmap(mem, st.st_size);
close(fd);
free(facts);
return (1);
}
@ -215,6 +220,7 @@ flash_update(int argc, char **argv)
warnx(" Image Product ID: %04x", fwheader->ProductID);
munmap(mem, st.st_size);
close(fd);
free(facts);
return (1);
}
}
@ -224,11 +230,13 @@ flash_update(int argc, char **argv)
warnx("Fail to update %s", argv[1]);
munmap(mem, st.st_size);
close(fd);
free(facts);
return (1);
}
munmap(mem, st.st_size);
close(fd);
free(facts);
printf("%s successfully updated\n", argv[1]);
return (0);
}