Skip to content

Commit

Permalink
Don't leak fd on sectorsize malloc failure
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ngie-eign committed Apr 20, 2016
1 parent 7661ad5 commit 3ae587f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sbin/savecore/savecore.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ DoFile(const char *savedir, const char *device)
temp = malloc(sectorsize);
if (temp == NULL) {
syslog(LOG_ERR, "%m");
return;
goto closefd;
}
}
if (lseek(fd, lasthd, SEEK_SET) != lasthd ||
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit 3ae587f

Please sign in to comment.