summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_ctf.c
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-02-19 21:10:01 +0000
committerdim <dim@FreeBSD.org>2015-02-19 21:10:01 +0000
commit184b3c7999c408b8e298b506ccfdff9d81c9ffd5 (patch)
treece81406a23f77fa9f935f0d6503dc58b5deb2300 /sys/kern/kern_ctf.c
parentd27bd4650ea928097e260433cb5c69be0dda440f (diff)
parentcc473808295d491ace3ff752290fb393824e4f79 (diff)
downloadFreeBSD-src-184b3c7999c408b8e298b506ccfdff9d81c9ffd5.zip
FreeBSD-src-184b3c7999c408b8e298b506ccfdff9d81c9ffd5.tar.gz
Merging ^/head r278916 through r279022.
Diffstat (limited to 'sys/kern/kern_ctf.c')
-rw-r--r--sys/kern/kern_ctf.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/sys/kern/kern_ctf.c b/sys/kern/kern_ctf.c
index 319414c..15bae04 100644
--- a/sys/kern/kern_ctf.c
+++ b/sys/kern/kern_ctf.c
@@ -121,10 +121,7 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
NDFREE(&nd, NDF_ONLY_PNBUF);
/* Allocate memory for the FLF header. */
- if ((hdr = malloc(sizeof(*hdr), M_LINKER, M_WAITOK)) == NULL) {
- error = ENOMEM;
- goto out;
- }
+ hdr = malloc(sizeof(*hdr), M_LINKER, M_WAITOK);
/* Read the ELF header. */
if ((error = vn_rdwr(UIO_READ, nd.ni_vp, hdr, sizeof(*hdr),
@@ -146,10 +143,7 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
}
/* Allocate memory for all the section headers */
- if ((shdr = malloc(nbytes, M_LINKER, M_WAITOK)) == NULL) {
- error = ENOMEM;
- goto out;
- }
+ shdr = malloc(nbytes, M_LINKER, M_WAITOK);
/* Read all the section headers */
if ((error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)shdr, nbytes,
@@ -171,11 +165,7 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
}
/* Allocate memory to buffer the section header strings. */
- if ((shstrtab = malloc(shdr[hdr->e_shstrndx].sh_size, M_LINKER,
- M_WAITOK)) == NULL) {
- error = ENOMEM;
- goto out;
- }
+ shstrtab = malloc(shdr[hdr->e_shstrndx].sh_size, M_LINKER, M_WAITOK);
/* Read the section header strings. */
if ((error = vn_rdwr(UIO_READ, nd.ni_vp, shstrtab,
@@ -238,10 +228,7 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
* Allocate memory for the compressed CTF data, including
* the header (which isn't compressed).
*/
- if ((raw = malloc(shdr[i].sh_size, M_LINKER, M_WAITOK)) == NULL) {
- error = ENOMEM;
- goto out;
- }
+ raw = malloc(shdr[i].sh_size, M_LINKER, M_WAITOK);
} else {
/*
* The CTF data is not compressed, so the ELF section
@@ -254,10 +241,7 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
* Allocate memory to buffer the CTF data in it's decompressed
* form.
*/
- if ((ctftab = malloc(sz, M_LINKER, M_WAITOK)) == NULL) {
- error = ENOMEM;
- goto out;
- }
+ ctftab = malloc(sz, M_LINKER, M_WAITOK);
/*
* Read the CTF data into the raw buffer if compressed, or
@@ -293,7 +277,9 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
zs.next_in = ((uint8_t *) raw) + sizeof(ctf_hdr);
zs.avail_out = sz - sizeof(ctf_hdr);
zs.next_out = ((uint8_t *) ctftab) + sizeof(ctf_hdr);
- if ((ret = inflate(&zs, Z_FINISH)) != Z_STREAM_END) {
+ ret = inflate(&zs, Z_FINISH);
+ inflateEnd(&zs);
+ if (ret != Z_STREAM_END) {
printf("%s(%d): zlib inflate returned %d\n", __func__, __LINE__, ret);
error = EIO;
goto out;
OpenPOWER on IntegriCloud