VPP-1486: stat segment file descriptor leak
Close the mmap file descriptor at first opportunity.
Change-Id: If8faa1de0a57dc7d8abb3eed97861813b841bd92
Signed-off-by: Ole Troan <ot@cisco.com>
diff --git a/src/vpp-api/client/stat_client.c b/src/vpp-api/client/stat_client.c
index 25a37f7..761c73f 100644
--- a/src/vpp-api/client/stat_client.c
+++ b/src/vpp-api/client/stat_client.c
@@ -141,16 +141,19 @@
if (fstat (mfd, &st) == -1)
{
+ close (mfd);
perror ("mmap fstat failed");
return -4;
}
if ((memaddr =
mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, mfd, 0)) == MAP_FAILED)
{
+ close (mfd);
perror ("mmap map failed");
return -5;
}
+ close (mfd);
sm->memory_size = st.st_size;
sm->shared_header = memaddr;
sm->directory_vector =