Skip to content

Commit

Permalink
intel-iommu: Fix double lock in get_domain_for_dev()
Browse files Browse the repository at this point in the history
stanse found the following double lock.

In get_domain_for_dev:
  spin_lock_irqsave(&device_domain_lock, flags);
  domain_exit(domain);
    domain_remove_dev_info(domain);
      spin_lock_irqsave(&device_domain_lock, flags);
      spin_unlock_irqrestore(&device_domain_lock, flags);
  spin_unlock_irqrestore(&device_domain_lock, flags);

This happens when the domain is created by another CPU at the same time 
as this function is creating one, and the other CPU wins the race to 
attach it to the device in question, so we have to destroy our own 
newly-created one.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
Jiri Slaby authored and David Woodhouse committed Jun 15, 2010
1 parent 25cbff1 commit 00dfff7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/pci/intel-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1874,14 +1874,15 @@ static struct dmar_domain *get_domain_for_dev(struct pci_dev *pdev, int gaw)
}
}
if (found) {
spin_unlock_irqrestore(&device_domain_lock, flags);
free_devinfo_mem(info);
domain_exit(domain);
domain = found;
} else {
list_add(&info->link, &domain->devices);
list_add(&info->global, &device_domain_list);
spin_unlock_irqrestore(&device_domain_lock, flags);
}
spin_unlock_irqrestore(&device_domain_lock, flags);
}

found_domain:
Expand Down

0 comments on commit 00dfff7

Please sign in to comment.