Skip to content

Commit

Permalink
KVM: don't free an unallocated irq source id
Browse files Browse the repository at this point in the history
Set assigned_dev->irq_source_id to -1 so that we can avoid freeing
a source ID which we never allocated.

Signed-off-by: Mark McLoughlin <[email protected]>
Signed-off-by: Avi Kivity <[email protected]>
  • Loading branch information
markmc authored and avikivity committed Dec 31, 2008
1 parent fdd897e commit f29b267
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ static void kvm_free_assigned_device(struct kvm *kvm,
pci_disable_msi(assigned_dev->dev);

kvm_unregister_irq_ack_notifier(&assigned_dev->ack_notifier);
kvm_free_irq_source_id(kvm, assigned_dev->irq_source_id);

if (assigned_dev->irq_source_id != -1)
kvm_free_irq_source_id(kvm, assigned_dev->irq_source_id);
assigned_dev->irq_source_id = -1;

if (cancel_work_sync(&assigned_dev->interrupt_work))
/* We had pending work. That means we will have to take
Expand Down Expand Up @@ -466,7 +469,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
match->host_busnr = assigned_dev->busnr;
match->host_devfn = assigned_dev->devfn;
match->dev = dev;

match->irq_source_id = -1;
match->kvm = kvm;

list_add(&match->list, &kvm->arch.assigned_dev_head);
Expand Down

0 comments on commit f29b267

Please sign in to comment.