From db9eae1c49fe2766a7709d7b2c4cdfcd91b9c25b Mon Sep 17 00:00:00 2001 From: Xu He Jie Date: Thu, 27 Oct 2011 10:15:13 +0800 Subject: kvm_init didn't set return value after create vm failed And kvm_ioctl(s, KVM_CREATE_VM, 0)'s return value can be < -1, so change the check of vmfd at label 'err'. Signed-off-by: Xu He Jie Signed-off-by: Anthony Liguori --- kvm-all.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kvm-all.c b/kvm-all.c index c09ddf7..4c466d6 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -740,6 +740,7 @@ int kvm_init(void) fprintf(stderr, "Please add the 'switch_amode' kernel parameter to " "your host kernel command line\n"); #endif + ret = s->vmfd; goto err; } @@ -798,7 +799,7 @@ int kvm_init(void) err: if (s) { - if (s->vmfd != -1) { + if (s->vmfd >= 0) { close(s->vmfd); } if (s->fd != -1) { -- cgit v1.1