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 <behlendorf1@llnl.gov>
Signed-off-by: Jorgen Lundman <lundman@lundman.net>
Closes #11683
This commit is contained in:
Jorgen Lundman 2021-03-06 05:22:57 +09:00 committed by GitHub
parent ba74de88c0
commit 8a6d444825
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -555,8 +555,12 @@ abd_get_offset_impl(abd_t *abd, abd_t *sabd, size_t off, size_t size)
abd_t * abd_t *
abd_get_offset_struct(abd_t *abd, abd_t *sabd, size_t off, size_t size) abd_get_offset_struct(abd_t *abd, abd_t *sabd, size_t off, size_t size)
{ {
abd_t *result;
abd_init_struct(abd); 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 * abd_t *