Skip to contentSkip to conversation

uprobe: fix memory leak

PATCH In review Kris Van Hees 2 participants 2 messages Apr 28

lore
Share & tools
lore
#0 lore raw

PATCH 6/6 uprobe: fix memory leak

---
 libdtrace/dt_prov_uprobe.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
libdtrace/dt_prov_uprobe.c +11 -3
index e575b0724..0e0f6a560 100644
@@ -434,6 +434,7 @@ static void probe_destroy_underlying(dtrace_hdl_t *dtp, void *datap)
 static void probe_destroy(dtrace_hdl_t *dtp, void *datap)
 {
 	free_probe_list(dtp, datap);
+	dt_free(dtp, datap);
 }
 
 static void detach(dtrace_hdl_t *dtp, const dt_probe_t *uprp)
@@ -1701,8 +1702,14 @@ oom:
 	return dt_set_errno(dtp, EDT_NOMEM);
 }
 
-/* Clean up the private provider data. */
-static void destroy(dtrace_hdl_t *dtp, void *arg)
+/* Clean up the private uproobe provider data. */
+static void destroy_uprobe(dtrace_hdl_t *dtp, void *arg)
+{
+	dt_free(dtp, arg);
+}
+
+/* Clean up the private USDT provider data. */
+static void destroy_usdt(dtrace_hdl_t *dtp, void *arg)
 {
 	dt_htab_destroy((dt_htab_t *)arg);
 }
@@ -1720,6 +1727,7 @@ dt_provimpl_t	dt_uprobe = {
 	.detach		= &detach,
 	.probe_destroy	= &probe_destroy_underlying,
 	.add_probe	= &add_probe_uprobe,
+	.destroy	= &destroy_uprobe,
 };
 
 /*
@@ -1746,7 +1754,7 @@ dt_provimpl_t	dt_usdt = {
 	.probe_destroy	= &probe_destroy,
 	.discover	= &discover,
 	.add_probe	= &add_probe_usdt,
-	.destroy	= &destroy,
+	.destroy	= &destroy_usdt,
 };
 
 /*
Signature · 1 line
2.53.0