system-monitor: don't leak /proc/mounts fd.
authorKrisztian Litkey <krisztian.litkey@intel.com>
Thu, 6 Nov 2014 09:48:00 +0000 (11:48 +0200)
committerKrisztian Litkey <krisztian.litkey@intel.com>
Thu, 8 Jan 2015 16:37:19 +0000 (18:37 +0200)
Change-Id: Ib70d20140fee4b1a6803c7f8a7388282846f376d

src/plugins/system-monitor/cgroup.c

index ce80f06..44b9df2 100644 (file)
@@ -333,7 +333,11 @@ static const char *find_mount_point(cgroup_type_t type)
     if ((fd = open("/proc/mounts", O_RDONLY)) < 0)
         return NULL;
 
-    if ((l = read(fd, mounts, sizeof(mounts) - 1)) <= 0)
+    l = read(fd, mounts, sizeof(mounts) - 1);
+
+    close(fd);
+
+    if (l <= 0)
         return NULL;
     else
         mounts[l] = '\0';