[PATCH] kvm tools: fix instances enumeration

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

 



Calling readdir() with NULL dirp leads to segfault.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@xxxxxxxxxx>
---
 tools/kvm/kvm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c
index cd3cb19..2ac7b38 100644
--- a/tools/kvm/kvm.c
+++ b/tools/kvm/kvm.c
@@ -172,7 +172,7 @@ int kvm__enumerate_instances(void (*callback)(const char *name, int pid))
 	sprintf(full_name, "%s/%s", HOME_DIR, KVM_PID_FILE_PATH);
 	dir = opendir(full_name);
 
-	for (;;) {
+	for (;dir;) {
 		readdir_r(dir, &entry, &result);
 		if (result == NULL)
 			break;

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux