After fips_mct_sha_test() and fips_mct_shake_test() complete,
vec.pt.val is freed but left as a non-NULL dangling pointer.
Since vec is a file-scope global, the next SHA algorithm's AFT
test calls parse_uint8_hex_str(&vec.pt), which checks val->val
and calls rte_free() on the stale pointer, producing:

  EAL: Error: Invalid memory

Fix by setting vec.pt.val to NULL after rte_free() at the end
of both MCT functions so the subsequent rte_free() guard in
parse_uint8_hex_str() skips the already-freed pointer.

Signed-off-by: Kai Ji <[email protected]>
---
 examples/fips_validation/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index daf273bc85..cfb5f0124c 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -2610,6 +2610,7 @@ fips_mct_sha_test(void)
                rte_free(md[i].val);
 
        rte_free(vec.pt.val);
+       vec.pt.val = NULL;
 
        rte_free(val.val);
        return 0;
@@ -2698,6 +2699,7 @@ fips_mct_shake_test(void)
 
        rte_free(md.val);
        rte_free(vec.pt.val);
+       vec.pt.val = NULL;
        rte_free(val.val);
        return 0;
 }
-- 
2.43.0

Reply via email to