svn commit: r298315 - head/sbin/savecore

Garrett Cooper ngie at FreeBSD.org
Wed Apr 20 00:49:50 UTC 2016


Author: ngie
Date: Wed Apr 20 00:49:49 2016
New Revision: 298315
URL: https://svnweb.freebsd.org/changeset/base/298315

Log:
  Don't leak fd on sectorsize malloc failure
  
  Also, call endfsent after calling getfsent (i.e. when not explicitly called
  with a swap device) for code cleanliness
  
  CID: 1354785
  Differential Revision: https://reviews.freebsd.org/D6014
  X-MFC with: r298076
  Reported by: Coverity
  Reviewed by: cem
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sbin/savecore/savecore.c

Modified: head/sbin/savecore/savecore.c
==============================================================================
--- head/sbin/savecore/savecore.c	Wed Apr 20 00:49:37 2016	(r298314)
+++ head/sbin/savecore/savecore.c	Wed Apr 20 00:49:49 2016	(r298315)
@@ -502,7 +502,7 @@ DoFile(const char *savedir, const char *
 		temp = malloc(sectorsize);
 		if (temp == NULL) {
 			syslog(LOG_ERR, "%m");
-			return;
+			goto closefd;
 		}
 	}
 	if (lseek(fd, lasthd, SEEK_SET) != lasthd ||
@@ -845,6 +845,7 @@ main(int argc, char **argv)
 				continue;
 			DoFile(savedir, fsp->fs_spec);
 		}
+		endfsent();
 	} else {
 		for (i = 0; i < argc; i++)
 			DoFile(savedir, argv[i]);


More information about the svn-src-head mailing list