From b8bfe5bcc151c5b033a34ebf8a9a0b4e2af9d67f Mon Sep 17 00:00:00 2001 From: Liam Mark Date: Tue, 13 Sep 2016 14:52:27 -0700 Subject: iommu: msm: use list_for_each_entry_safe for deletion Use list_for_each_entry_safe to safely delete mappings while iterating over the mappings list. CRs-Fixed: 1067012 Change-Id: I5326ee8e58d291b1d9b07649b87632d7e9102e0d Signed-off-by: Liam Mark --- drivers/iommu/msm_dma_iommu_mapping.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/msm_dma_iommu_mapping.c b/drivers/iommu/msm_dma_iommu_mapping.c index a035ebd5af7e..334f4e95c068 100644 --- a/drivers/iommu/msm_dma_iommu_mapping.c +++ b/drivers/iommu/msm_dma_iommu_mapping.c @@ -358,10 +358,12 @@ int msm_dma_unmap_all_for_dev(struct device *dev) meta_node = rb_first(root); while (meta_node) { struct msm_iommu_map *iommu_map; + struct msm_iommu_map *iommu_map_next; meta = rb_entry(meta_node, struct msm_iommu_meta, node); mutex_lock(&meta->lock); - list_for_each_entry(iommu_map, &meta->iommu_maps, lnode) + list_for_each_entry_safe(iommu_map, iommu_map_next, + &meta->iommu_maps, lnode) if (iommu_map->dev == dev) if (!kref_put(&iommu_map->ref, msm_iommu_map_release)) -- cgit v1.2.3