On Sat, Feb 04, 2012 at 07:54:38PM +0200, Pekka Enberg wrote: > On Sat, 4 Feb 2012, Cyrill Gorcunov wrote: > >Index: linux-2.6.git/tools/kvm/kvm.c > >=================================================================== > >--- linux-2.6.git.orig/tools/kvm/kvm.c > >+++ linux-2.6.git/tools/kvm/kvm.c > >@@ -123,10 +123,12 @@ static int kvm__check_extensions(struct > >static struct kvm *kvm__new(void) > >{ > > struct kvm *kvm = calloc(1, sizeof(*kvm)); > >- > > if (!kvm) > > return ERR_PTR(-ENOMEM); > > > >+ kvm->sys_fd = -1; > >+ kvm->vm_fd = -1; > >+ > > return kvm; > >} > > > >@@ -394,9 +396,12 @@ struct kvm *kvm__init(const char *kvm_de > > kvm_ipc__start(kvm__create_socket(kvm)); > > kvm_ipc__register_handler(KVM_IPC_PID, kvm__pid); > > return kvm; > >+ > >cleanup: > >- close(kvm->vm_fd); > >- close(kvm->sys_fd); > >+ if (kvm->vm_fd >= 0) > >+ close(kvm->vm_fd); > >+ if (kvm->sys_fd >= 0) > >+ close(kvm->sys_fd); > > No, please don't do this! Use specific error handling labels instead. > Strictly speaking, kvm__init need more serious rewrite together with kvm__arch_init/kvm_ipc__start/kvm_ipc__register_handler ret. vals tests, i'll do this a bit late. Cyrill -- 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