svn commit: r264820 - stable/9/sys/kern

Christian Brueffer brueffer at FreeBSD.org
Wed Apr 23 12:16:37 UTC 2014


Author: brueffer
Date: Wed Apr 23 12:16:36 2014
New Revision: 264820
URL: http://svnweb.freebsd.org/changeset/base/264820

Log:
  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)

Modified:
  stable/9/sys/kern/imgact_elf.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/imgact_elf.c
==============================================================================
--- stable/9/sys/kern/imgact_elf.c	Wed Apr 23 12:15:14 2014	(r264819)
+++ stable/9/sys/kern/imgact_elf.c	Wed Apr 23 12:16:36 2014	(r264820)
@@ -1742,14 +1742,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)
 		sbuf_bcat(sb, buf, size);
+	free(buf, M_TEMP);
 	*sizep = size;
 }
 


More information about the svn-src-all mailing list