From 9d2968fbb1f99f6d2589f600c7b75b26f828afd1 Mon Sep 17 00:00:00 2001 From: Uri Lublin Date: Thu, 19 Jun 2008 18:26:28 +0300 Subject: libkvm: kvm_init: check kvm context allocation and zero it Signed-off-by: Uri Lublin Signed-off-by: Avi Kivity --- libkvm/libkvm.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libkvm') diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c index 63fbcba0..a850caa3 100644 --- a/libkvm/libkvm.c +++ b/libkvm/libkvm.c @@ -236,6 +236,9 @@ kvm_context_t kvm_init(struct kvm_callbacks *callbacks, kvm_abi = r; kvm_page_size = getpagesize(); kvm = malloc(sizeof(*kvm)); + if (kvm == NULL) + goto out_close; + memset(kvm, 0, sizeof(*kvm)); kvm->fd = fd; kvm->vm_fd = -1; kvm->callbacks = callbacks; -- cgit v1.2.3