From e963273a779104424d69783117317e588e6f054b Mon Sep 17 00:00:00 2001 From: Serge Hallyn Date: Sat, 17 Oct 2015 21:16:12 -0500 Subject: [PATCH] coverity: free mounts on error path Signed-off-by: Serge Hallyn --- hooks/unmount-namespace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hooks/unmount-namespace.c b/hooks/unmount-namespace.c index 9b4033fbd..99b284481 100644 --- a/hooks/unmount-namespace.c +++ b/hooks/unmount-namespace.c @@ -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))) { -- 2.47.2