Skip to content

Commit

Permalink
coverity: free mounts on error path
Browse files Browse the repository at this point in the history
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
  • Loading branch information
hallyn committed Oct 18, 2015
1 parent 2d9ec00 commit e963273
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion hooks/unmount-namespace.c
Expand Up @@ -112,14 +112,17 @@ static int read_mounts(int procfd, struct mount **mp, size_t *countp) {
*countp = 0;

fd = openat(procfd, "self/mounts", O_RDONLY);
if (fd < 0)
if (fd < 0) {
free(mounts);
return 0;
}

mf = fdopen(fd, "r");
if (!mf) {
int error = errno;
close(fd);
errno = error;
free(mounts);
return 0;
}
while ((ent = getmntent(mf))) {
Expand Down

0 comments on commit e963273

Please sign in to comment.