iommu/amd: Fix cleanup_domain for mass device removal
authorJoerg Roedel <jroedel@suse.de>
Tue, 5 Aug 2014 15:50:15 +0000 (17:50 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 13 Sep 2014 22:41:45 +0000 (23:41 +0100)
commit36d724c9ec52f8c1dc29f2d9b98d5b82ff4e4e8b
tree59e5d699529588ff54cc75584ea088c4c6b8b676
parent4c39c21647ea2eb22029e0feafd106fbb76080e3
iommu/amd: Fix cleanup_domain for mass device removal

commit 9b29d3c6510407d91786c1cf9183ff4debb3473a upstream.

When multiple devices are detached in __detach_device, they
are also removed from the domains dev_list. This makes it
unsafe to use list_for_each_entry_safe, as the next pointer
might also not be in the list anymore after __detach_device
returns. So just repeatedly remove the first element of the
list until it is empty.

Tested-by: Marti Raudsepp <marti@juffo.org>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/iommu/amd_iommu.c