diff options
author | brueffer <brueffer@FreeBSD.org> | 2014-04-23 12:15:14 +0000 |
---|---|---|
committer | brueffer <brueffer@FreeBSD.org> | 2014-04-23 12:15:14 +0000 |
commit | d9c1f7d4465819a77ecbd2b9624e16cc6aa07dde (patch) | |
tree | e02967e1cab2f9bcbf97ef6cc062fb5da038d612 | |
parent | 031977611bb1377aff74c23b63f89342e7da156c (diff) | |
download | FreeBSD-src-d9c1f7d4465819a77ecbd2b9624e16cc6aa07dde.zip FreeBSD-src-d9c1f7d4465819a77ecbd2b9624e16cc6aa07dde.tar.gz |
MFC: r264422, r264471
Set buf to NULL only when we don't allocate memory,
and free buf unconditionally.
Found with: Coverity Prevent(tm)
Requested by: kib (r264471)
-rw-r--r-- | sys/kern/imgact_elf.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index f6da68e..8783670 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1740,14 +1740,16 @@ __elfN(note_threadmd)(void *arg, struct sbuf *sb, size_t *sizep) td = (struct thread *)arg; size = *sizep; - buf = NULL; if (size != 0 && sb != NULL) buf = malloc(size, M_TEMP, M_ZERO | M_WAITOK); + else + buf = NULL; size = 0; __elfN(dump_thread)(td, buf, &size); KASSERT(*sizep == size, ("invalid size")); if (size != 0 && sb != NULL) sbuf_bcat(sb, buf, size); + free(buf, M_TEMP); *sizep = size; } |