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
This commit is contained in:
Enji Cooper 2016-04-20 00:49:49 +00:00
parent 7661ad590f
commit 3ae587fde4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298315

View File

@ -502,7 +502,7 @@ DoFile(const char *savedir, const char *device)
temp = malloc(sectorsize); temp = malloc(sectorsize);
if (temp == NULL) { if (temp == NULL) {
syslog(LOG_ERR, "%m"); syslog(LOG_ERR, "%m");
return; goto closefd;
} }
} }
if (lseek(fd, lasthd, SEEK_SET) != lasthd || if (lseek(fd, lasthd, SEEK_SET) != lasthd ||
@ -845,6 +845,7 @@ main(int argc, char **argv)
continue; continue;
DoFile(savedir, fsp->fs_spec); DoFile(savedir, fsp->fs_spec);
} }
endfsent();
} else { } else {
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
DoFile(savedir, argv[i]); DoFile(savedir, argv[i]);