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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Sep 2014 16:03:57 +0000 (09:03 -0700)
commitb15dba9397aae1e091b047c9e3214bfbd1d17e04
treede80fdd69254510630efdf3beb8ccffc80c755bd
parent01d29ff71d3b123c443f8426d5540462e9d04b19
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iommu/amd_iommu.c