[PATCH] Fix closedir usage in virNumaGetPages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



virNumaGetPages calls closedir(dir) in cleanup and dir could
be NULL if we jump there from the failed opendir() call.

While it's not harmful on Linux, FreeBSD libc crashes [1], so
make sure that dir is not NULL before calling closedir.

1: http://lists.freebsd.org/pipermail/freebsd-standards/2014-January/002704.html
---
 src/util/virnuma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index c8e7f40..1048033 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -836,7 +836,8 @@ virNumaGetPages(int node,
     VIR_FREE(tmp_free);
     VIR_FREE(tmp_avail);
     VIR_FREE(tmp_size);
-    closedir(dir);
+    if (dir)
+        closedir(dir);
     VIR_FREE(path);
     return ret;
 }
-- 
1.9.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]