Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Apr 2014 12:15:14 +0000 (UTC)
From:      Christian Brueffer <brueffer@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r264819 - stable/10/sys/kern
Message-ID:  <201404231215.s3NCFE7F010483@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brueffer
Date: Wed Apr 23 12:15:14 2014
New Revision: 264819
URL: http://svnweb.freebsd.org/changeset/base/264819

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/10/sys/kern/imgact_elf.c
Directory Properties:
  stable/10/   (props changed)

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



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