astlpc: Add mctp_astlpc_destroy()
Provide an abstraction to cleanup memory to avoid false-positives with
leak sanitizers.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ib73506432eed108cb992cfc12b40c479b0321463
diff --git a/astlpc.c b/astlpc.c
index 1a75742..5b47b3d 100644
--- a/astlpc.c
+++ b/astlpc.c
@@ -402,6 +402,13 @@
return astlpc;
}
+void mctp_astlpc_destroy(struct mctp_binding_astlpc *astlpc)
+{
+ if (astlpc->priv_hdr)
+ __mctp_free(astlpc->priv_hdr);
+ __mctp_free(astlpc);
+}
+
#ifdef MCTP_HAVE_FILEIO
static int mctp_astlpc_init_fileio_lpc(struct mctp_binding_astlpc *astlpc)
{
diff --git a/libmctp-astlpc.h b/libmctp-astlpc.h
index e55f7a1..9759ff1 100644
--- a/libmctp-astlpc.h
+++ b/libmctp-astlpc.h
@@ -29,6 +29,7 @@
struct mctp_binding_astlpc *mctp_astlpc_init_ops(
const struct mctp_binding_astlpc_ops *ops,
void *ops_data, void *lpc_map);
+void mctp_astlpc_destroy(struct mctp_binding_astlpc *astlpc);
struct mctp_binding *mctp_binding_astlpc_core(struct mctp_binding_astlpc *b);