Fix test-i2c leak, and mctp_pktbuf storage alignment
- Ensure mctp_pktbuf storage is correctly aligned
- Deallocate mctp and i2c instances to avoid failure with asan.
These previously succeeded in CI so are both fixed in this commit.
Fixes: e5b941d9d764 ("i2c: Add binding for MCTP over I2C transport")
Fixes: 4a09e1dc4883 ("core: Reuse buffers for tx, allow message pools")
Change-Id: I747bfff6faf3a5b0a982ae266bcef02ecbc4ee8a
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
diff --git a/tests/test-utils.c b/tests/test-utils.c
index 5e78474..2a346fa 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -16,7 +16,7 @@
* the local EID as the destination */
struct mctp_binding_test {
struct mctp_binding binding;
- uint8_t tx_storage[MCTP_PKTBUF_SIZE(MCTP_BTU)];
+ uint8_t tx_storage[MCTP_PKTBUF_SIZE(MCTP_BTU)] PKTBUF_STORAGE_ALIGN;
};
static int mctp_binding_test_tx(struct mctp_binding *b, struct mctp_pktbuf *pkt)
diff --git a/tests/test_bridge.c b/tests/test_bridge.c
index 73705ba..40d5fb6 100644
--- a/tests/test_bridge.c
+++ b/tests/test_bridge.c
@@ -19,7 +19,7 @@
int rx_count;
int tx_count;
uint8_t last_pkt_data;
- uint8_t tx_storage[MCTP_PKTBUF_SIZE(MCTP_BTU)];
+ uint8_t tx_storage[MCTP_PKTBUF_SIZE(MCTP_BTU)] PKTBUF_STORAGE_ALIGN;
};
struct test_ctx {
diff --git a/tests/test_cmds.c b/tests/test_cmds.c
index 2646b8c..b4bf913 100644
--- a/tests/test_cmds.c
+++ b/tests/test_cmds.c
@@ -60,7 +60,7 @@
assert(test_endpoint != NULL);
assert(callback_ctx != NULL);
- uint8_t tx_storage[MCTP_PKTBUF_SIZE(MCTP_BTU)];
+ uint8_t tx_storage[MCTP_PKTBUF_SIZE(MCTP_BTU)] PKTBUF_STORAGE_ALIGN;
memset(test_binding, 0, sizeof(*test_binding));
test_binding->name = "test";
test_binding->version = 1;
diff --git a/tests/test_i2c.c b/tests/test_i2c.c
index 067d551..89e7744 100644
--- a/tests/test_i2c.c
+++ b/tests/test_i2c.c
@@ -259,5 +259,10 @@
test_neigh_expiry(tx_test, rx_test);
+ free(tx_test->i2c);
+ free(rx_test->i2c);
+ mctp_destroy(tx_test->mctp);
+ mctp_destroy(rx_test->mctp);
+
return 0;
}