In kvm__new() we use calloc() to allocate the kvm structure, which
initialises the memory to 0.

In kvm__init() if we hit an error before sys_fd and vm_fd are opened
we go to cleanup which closes sys_fd and vm_fd. Because they were
initialised to zero this has the effect of closing stdin. Because
we have closed stdin term_cleanup() doesn't work and the users terminal
is fubared.

Set both fd's to -1 in kvm__new() to avoid the problem.

Signed-off-by: Michael Ellerman <[email protected]>
---
 tools/kvm/kvm.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c
index 74e37ae..7b72f1e 100644
--- a/tools/kvm/kvm.c
+++ b/tools/kvm/kvm.c
@@ -127,6 +127,8 @@ static struct kvm *kvm__new(void)
        if (!kvm)
                return ERR_PTR(-ENOMEM);
 
+       kvm->vm_fd = kvm->sys_fd = -1;
+
        return kvm;
 }
 
-- 
1.7.7.3

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

Reply via email to