From 064f7ef2e8d8e2a7500ffdfe4d55d3ebc48f8226 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Tue, 19 Feb 2013 17:22:08 +0000 Subject: [PATCH] fs: Free parent_dir later in lsmount and flushmount If lsmount or flushmount encounter an error, then they may include the contents of parent_dir in their error message. However, in both cases, this was freed a couple of lines earlier. Just move the free() later, so that the contents of this variable are still available. Caught by clang-analyzer Change-Id: Ideba52b7ba98f034baf923194007239a6cf0221f Reviewed-on: http://gerrit.openafs.org/9193 Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/venus/fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/venus/fs.c b/src/venus/fs.c index c05bfe50c..7d8fb8844 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -1855,7 +1855,6 @@ ListMountCmd(struct cmd_syndesc *as, void *arock) code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1); free(last_component); - free(parent_dir); if (code == 0) { printf("'%s' is a %smount point for volume '%s'\n", ti->data, @@ -1869,6 +1868,7 @@ ListMountCmd(struct cmd_syndesc *as, void *arock) } error = 1; } + free(parent_dir); } return error; } @@ -4158,7 +4158,6 @@ FlushMountCmd(struct cmd_syndesc *as, void *arock) code = pioctl(parent_dir, VIOC_AFS_FLUSHMOUNT, &blob, 1); free(last_component); - free(parent_dir); if (code != 0) { if (errno == EINVAL) { @@ -4168,6 +4167,7 @@ FlushMountCmd(struct cmd_syndesc *as, void *arock) } error = 1; } + free(parent_dir); } return error; } -- 2.39.5