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 <behlendorf1@llnl.gov> Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Closes #13973
This commit is contained in:
parent
af2e53f62c
commit
3830858c5c
|
@ -2716,6 +2716,10 @@ dmu_send_obj(const char *pool, uint64_t tosnap, uint64_t fromsnap,
|
||||||
dspp.numfromredactsnaps = NUM_SNAPS_NOT_REDACTED;
|
dspp.numfromredactsnaps = NUM_SNAPS_NOT_REDACTED;
|
||||||
err = dmu_send_impl(&dspp);
|
err = dmu_send_impl(&dspp);
|
||||||
}
|
}
|
||||||
|
if (dspp.fromredactsnaps)
|
||||||
|
kmem_free(dspp.fromredactsnaps,
|
||||||
|
dspp.numfromredactsnaps * sizeof (uint64_t));
|
||||||
|
|
||||||
dsl_dataset_rele(dspp.to_ds, FTAG);
|
dsl_dataset_rele(dspp.to_ds, FTAG);
|
||||||
return (err);
|
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. */
|
/* dmu_send_impl will call dsl_pool_rele for us. */
|
||||||
err = dmu_send_impl(&dspp);
|
err = dmu_send_impl(&dspp);
|
||||||
} else {
|
} else {
|
||||||
|
if (dspp.fromredactsnaps)
|
||||||
|
kmem_free(dspp.fromredactsnaps,
|
||||||
|
dspp.numfromredactsnaps *
|
||||||
|
sizeof (uint64_t));
|
||||||
dsl_pool_rele(dspp.dp, FTAG);
|
dsl_pool_rele(dspp.dp, FTAG);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue