iommu/amd: Fix device_state reference counting
authorJoerg Roedel <jroedel@suse.de>
Wed, 30 Jul 2014 14:04:39 +0000 (16:04 +0200)
committerJoerg Roedel <jroedel@suse.de>
Wed, 30 Jul 2014 14:07:50 +0000 (16:07 +0200)
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>
drivers/iommu/amd_iommu_v2.c

index 524fd67a85b1bd3fe82f93769d949654f6c4fa01..2de13be17268b1b6bbd4da55ee38cd25b0f71dd2 100644 (file)
@@ -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)
@@ -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);
This page took 0.024744 seconds and 5 git commands to generate.