Clang's context analysis reports:
iommu_api.c:380:1: error: __ctx_lock_RCU 'RCU' is not held on every path
through here [-Werror,-Wthread-safety-analysis]
mm_iommu_is_devmem() takes the RCU read lock to walk the preregistered
device-memory list. On a match it returned true from inside the loop and
skipped rcu_read_unlock(). Hence fix it.
Fixes: b5952f8125ae ("powerpc/mm/book3s64/iommu: fix some RCU-list locks")
Signed-off-by: Ritesh Harjani (IBM) <[email protected]>
---
arch/powerpc/mm/book3s64/iommu_api.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/mm/book3s64/iommu_api.c
b/arch/powerpc/mm/book3s64/iommu_api.c
index 60d00c9e7f19..56d9aa6cc8e2 100644
--- a/arch/powerpc/mm/book3s64/iommu_api.c
+++ b/arch/powerpc/mm/book3s64/iommu_api.c
@@ -356,6 +356,7 @@ bool mm_iommu_is_devmem(struct mm_struct *mm, unsigned long
hpa,
{
struct mm_iommu_table_group_mem_t *mem;
unsigned long end;
+ bool ret = false;
rcu_read_lock();
list_for_each_entry_rcu(mem, &mm->context.iommu_group_mem_list, next) {
@@ -371,12 +372,13 @@ bool mm_iommu_is_devmem(struct mm_struct *mm, unsigned
long hpa,
* and the caller needs to distinguish this situation.
*/
*size = min(1UL << pageshift, end - hpa);
- return true;
+ ret = true;
+ break;
}
}
rcu_read_unlock();
- return false;
+ return ret;
}
EXPORT_SYMBOL_GPL(mm_iommu_is_devmem);
--
2.39.5