Skip to content

Commit 6ccfa59

Browse files
ryaotonyhutter
authored andcommitted
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 openzfs#13973
1 parent 165577d commit 6ccfa59

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

module/zfs/dmu_send.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,6 +2716,10 @@ dmu_send_obj(const char *pool, uint64_t tosnap, uint64_t fromsnap,
27162716
dspp.numfromredactsnaps = NUM_SNAPS_NOT_REDACTED;
27172717
err = dmu_send_impl(&dspp);
27182718
}
2719+
if (dspp.fromredactsnaps)
2720+
kmem_free(dspp.fromredactsnaps,
2721+
dspp.numfromredactsnaps * sizeof (uint64_t));
2722+
27192723
dsl_dataset_rele(dspp.to_ds, FTAG);
27202724
return (err);
27212725
}
@@ -2924,6 +2928,10 @@ dmu_send(const char *tosnap, const char *fromsnap, boolean_t embedok,
29242928
/* dmu_send_impl will call dsl_pool_rele for us. */
29252929
err = dmu_send_impl(&dspp);
29262930
} else {
2931+
if (dspp.fromredactsnaps)
2932+
kmem_free(dspp.fromredactsnaps,
2933+
dspp.numfromredactsnaps *
2934+
sizeof (uint64_t));
29272935
dsl_pool_rele(dspp.dp, FTAG);
29282936
}
29292937
} else {

0 commit comments

Comments
 (0)