Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Apr 2014 21:02:20 +0000 (UTC)
From:      Christian Brueffer <brueffer@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r264471 - head/sys/kern
Message-ID:  <201404142102.s3EL2KMp037907@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brueffer
Date: Mon Apr 14 21:02:20 2014
New Revision: 264471
URL: http://svnweb.freebsd.org/changeset/base/264471

Log:
  Refine r264422: set buf to NULL only when we don't allocate memory,
  and free buf unconditionally.
  
  Requested by:	kib
  MFC after:	1 week

Modified:
  head/sys/kern/imgact_elf.c

Modified: head/sys/kern/imgact_elf.c
==============================================================================
--- head/sys/kern/imgact_elf.c	Mon Apr 14 20:51:04 2014	(r264470)
+++ head/sys/kern/imgact_elf.c	Mon Apr 14 21:02:20 2014	(r264471)
@@ -1740,16 +1740,16 @@ __elfN(note_threadmd)(void *arg, struct 
 
 	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;
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404142102.s3EL2KMp037907>