Cleanup: Simplify userspace abd_free_chunks()

Clang's static analyzer complained that we could use after free here if
the inner loop ever iterated. That is a false positive, but upon
inspection, the userland abd_alloc_chunks() function never will put
multiple consecutive pages into a `struct scatterlist`, so there is no
need to loop. We delete the inner loop.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14042
This commit is contained in:
Richard Yao 2022-10-15 22:54:57 -04:00 committed by Brian Behlendorf
parent 6ae2f90888
commit 9a8039439a

View File

@ -597,11 +597,9 @@ abd_free_chunks(abd_t *abd)
struct scatterlist *sg;
abd_for_each_sg(abd, sg, n, i) {
for (int j = 0; j < sg->length; j += PAGESIZE) {
struct page *p = nth_page(sg_page(sg), j >> PAGE_SHIFT);
struct page *p = nth_page(sg_page(sg), 0);
umem_free(p, PAGESIZE);
}
}
abd_free_sg_table(abd);
}