diff options
author | Richard Yao <[email protected]> | 2022-10-18 19:03:33 -0400 |
---|---|---|
committer | Tony Hutter <[email protected]> | 2022-12-01 12:39:42 -0800 |
commit | 3830858c5cb4d209b1a05e6a3dde6b77cb88f2b3 (patch) | |
tree | b22296f1b594cd513e415fc31a655ba6693c686e /module | |
parent | af2e53f62c0aae6cd18c5e450977711d16b1cedb (diff) |
Fix memory leaks in dmu_send()/dmu_send_obj()
If we encounter an EXDEV error when using the redacted snapshots
feature, the memory used by dspp.fromredactsnaps is leaked.
Clang's static analyzer caught this during an experiment in which I had
annotated various headers in an attempt to improve the results of static
analysis.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes #13973
Diffstat (limited to 'module')
-rw-r--r-- | module/zfs/dmu_send.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/module/zfs/dmu_send.c b/module/zfs/dmu_send.c index 390afba92..20ec4ac17 100644 --- a/module/zfs/dmu_send.c +++ b/module/zfs/dmu_send.c @@ -2716,6 +2716,10 @@ dmu_send_obj(const char *pool, uint64_t tosnap, uint64_t fromsnap, dspp.numfromredactsnaps = NUM_SNAPS_NOT_REDACTED; err = dmu_send_impl(&dspp); } + if (dspp.fromredactsnaps) + kmem_free(dspp.fromredactsnaps, + dspp.numfromredactsnaps * sizeof (uint64_t)); + dsl_dataset_rele(dspp.to_ds, FTAG); return (err); } @@ -2924,6 +2928,10 @@ dmu_send(const char *tosnap, const char *fromsnap, boolean_t embedok, /* dmu_send_impl will call dsl_pool_rele for us. */ err = dmu_send_impl(&dspp); } else { + if (dspp.fromredactsnaps) + kmem_free(dspp.fromredactsnaps, + dspp.numfromredactsnaps * + sizeof (uint64_t)); dsl_pool_rele(dspp.dp, FTAG); } } else { |