Skip to content

Commit

Permalink
Fix abd_get_offset_struct() may allocate new abd
Browse files Browse the repository at this point in the history
Even when supplied with an abd to abd_get_offset_struct(), the call
to abd_get_offset_impl() can allocate a different abd. Ensure to
call abd_fini_struct() on the abd that is not used.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Jorgen Lundman <[email protected]>
Closes #11683
  • Loading branch information
lundman authored Mar 5, 2021
1 parent ba74de8 commit 8a6d444
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion module/zfs/abd.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,12 @@ abd_get_offset_impl(abd_t *abd, abd_t *sabd, size_t off, size_t size)
abd_t *
abd_get_offset_struct(abd_t *abd, abd_t *sabd, size_t off, size_t size)
{
abd_t *result;
abd_init_struct(abd);
return (abd_get_offset_impl(abd, sabd, off, size));
result = abd_get_offset_impl(abd, sabd, off, size);
if (result != abd)
abd_fini_struct(abd);
return (result);
}

abd_t *
Expand Down

0 comments on commit 8a6d444

Please sign in to comment.