KVM: Properly lock PIT creation
Otherwise, two threads can create a PIT in parallel and cause a memory leak. Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
@@ -548,9 +548,7 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm)
|
||||
if (!pit)
|
||||
return NULL;
|
||||
|
||||
mutex_lock(&kvm->lock);
|
||||
pit->irq_source_id = kvm_request_irq_source_id(kvm);
|
||||
mutex_unlock(&kvm->lock);
|
||||
if (pit->irq_source_id < 0) {
|
||||
kfree(pit);
|
||||
return NULL;
|
||||
|
Reference in New Issue
Block a user