From: Avi Kivity Date: Tue, 11 Nov 2008 11:09:36 +0000 (+0200) Subject: KVM: Fix pit memory leak if unable to allocate irq source id X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=e17d1dc0863767bab8fde4ba9be92c7f79e7fe50;p=openwrt%2Fstaging%2Fblogic.git KVM: Fix pit memory leak if unable to allocate irq source id Reported-By: Daniel Marjamäki Signed-off-by: Avi Kivity --- diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 8772dc946823..59ebd37ad79e 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c @@ -548,8 +548,10 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm) mutex_lock(&kvm->lock); pit->irq_source_id = kvm_request_irq_source_id(kvm); mutex_unlock(&kvm->lock); - if (pit->irq_source_id < 0) + if (pit->irq_source_id < 0) { + kfree(pit); return NULL; + } mutex_init(&pit->pit_state.lock); mutex_lock(&pit->pit_state.lock);