Skip to content

Commit 8a6d444

Browse files
authored
Fix abd_get_offset_struct() may allocate new abd
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
1 parent ba74de8 commit 8a6d444

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

module/zfs/abd.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,12 @@ abd_get_offset_impl(abd_t *abd, abd_t *sabd, size_t off, size_t size)
555555
abd_t *
556556
abd_get_offset_struct(abd_t *abd, abd_t *sabd, size_t off, size_t size)
557557
{
558+
abd_t *result;
558559
abd_init_struct(abd);
559-
return (abd_get_offset_impl(abd, sabd, off, size));
560+
result = abd_get_offset_impl(abd, sabd, off, size);
561+
if (result != abd)
562+
abd_fini_struct(abd);
563+
return (result);
560564
}
561565

562566
abd_t *

0 commit comments

Comments
 (0)