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)
committerZefan Li <lizefan@huawei.com>
Thu, 25 Sep 2014 03:49:11 +0000 (11:49 +0800)
commit77e5657567adc61ab425a070c5a9ec13b20913e8
tree07956e00130747421b9f235927c4d81b4bed6c1c
parentdb83744afb3a43a21722d3bb17c8e1e8da5a9cf7
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: Zefan Li <lizefan@huawei.com>
drivers/iommu/amd_iommu.c