mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-07 00:50:50 +00:00
Plug leaks
Reported by: Coverity CID: 1340155 and 1340156 MFC after: 1 week
This commit is contained in:
parent
29bda43fa4
commit
4ecb514126
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298374
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue