]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
kvm tools: fix instances enumeration
authorKonstantin Khlebnikov <khlebnikov@openvz.org>
Sun, 10 Jul 2011 12:13:27 +0000 (16:13 +0400)
committerPekka Enberg <penberg@kernel.org>
Sun, 10 Jul 2011 12:21:58 +0000 (15:21 +0300)
Calling readdir() with NULL dirp leads to segfault.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
[ penberg@kernel.org: use 'while' instead of 'for' ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/kvm.c

index cd3cb1927733f67641bf44a527b93ce2736b4d79..a4a29b204af3f63849c34d0fcdfb20286f9626b0 100644 (file)
@@ -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 (;;) {
+       while (dir != NULL) {
                readdir_r(dir, &entry, &result);
                if (result == NULL)
                        break;