From e3e2951f67a26e55bfa3eb4fca5731a3971bde20 Mon Sep 17 00:00:00 2001 From: brueffer Date: Mon, 14 Apr 2014 21:02:20 +0000 Subject: [PATCH] Refine r264422: set buf to NULL only when we don't allocate memory, and free buf unconditionally. Requested by: kib MFC after: 1 week --- sys/kern/imgact_elf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index d7e7bfc0878e..591094e5af96 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1740,16 +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) { + if (size != 0 && sb != NULL) sbuf_bcat(sb, buf, size); - free(buf, M_TEMP); - } + free(buf, M_TEMP); *sizep = size; }