diff options
author | Jorgen Lundman <[email protected]> | 2021-03-06 05:22:57 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-05 12:22:57 -0800 |
commit | 8a6d4448257320ce8afc67ecea25b434f094a304 (patch) | |
tree | 86ed0cecb78cdf1307a73f1e19caa750821b5bc1 /module | |
parent | ba74de88c0891f4f40a6841db97668dfdac07b18 (diff) |
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
Diffstat (limited to 'module')
-rw-r--r-- | module/zfs/abd.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/module/zfs/abd.c b/module/zfs/abd.c index 7d3a2f6d6..1e6645c90 100644 --- a/module/zfs/abd.c +++ b/module/zfs/abd.c @@ -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 * |