Skip to content

Commit

Permalink
iommu/amd: Fix device_state reference counting
Browse files Browse the repository at this point in the history
The references to the device state are not dropped
everywhere. This might cause a dead-lock in
amd_iommu_free_device(). Fix it.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
Tested-by: Oded Gabbay <oded.gabbay@amd.com>
  • Loading branch information
Joerg Roedel committed Jul 30, 2014
1 parent 8301da5 commit 75058a3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/iommu/amd_iommu_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ static void free_pasid_states(struct device_state *dev_state)

put_pasid_state_wait(pasid_state); /* Reference taken in
amd_iommu_pasid_bind */

/* Drop reference taken in amd_iommu_bind_pasid */
put_device_state(dev_state);
}

if (dev_state->pasid_levels == 2)
Expand Down Expand Up @@ -748,6 +751,10 @@ void amd_iommu_unbind_pasid(struct pci_dev *pdev, int pasid)
put_pasid_state_wait(pasid_state); /* Reference taken in
amd_iommu_pasid_bind */
out:
/* Drop reference taken in this function */
put_device_state(dev_state);

/* Drop reference taken in amd_iommu_bind_pasid */
put_device_state(dev_state);
}
EXPORT_SYMBOL(amd_iommu_unbind_pasid);
Expand Down

0 comments on commit 75058a3

Please sign in to comment.