Skip to content

Commit

Permalink
Cleanup: Simplify userspace abd_free_chunks()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes openzfs#14042
  • Loading branch information
ryao authored and andrewc12 committed Nov 9, 2022
1 parent 57ffd98 commit 96217d6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions module/os/linux/zfs/abd_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,8 @@ 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);
umem_free_aligned(p, PAGESIZE);
}
struct page *p = nth_page(sg_page(sg), 0);
umem_free_aligned(p, PAGESIZE);
}
abd_free_sg_table(abd);
}
Expand Down

0 comments on commit 96217d6

Please sign in to comment.