test/crypto: fix build with GCC 11
authorKevin Traynor <ktraynor@redhat.com>
Wed, 5 May 2021 08:53:14 +0000 (09:53 +0100)
committerAkhil Goyal <gakhil@marvell.com>
Wed, 19 May 2021 12:54:29 +0000 (14:54 +0200)
Fix the allocation for sessions, to prevent an array-bounds
warning with GCC 11. Set the not created session to NULL.

Fixes: 202d375c60bc ("app/test: add cryptodev unit and performance tests")
Cc: stable@dpdk.org
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
app/test/test_cryptodev.c

index c68684b..39db52b 100644 (file)
@@ -10748,8 +10748,8 @@ test_multi_session(void)
        rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
 
        sessions = rte_malloc(NULL,
-                       (sizeof(struct rte_cryptodev_sym_session *) *
-                       MAX_NB_SESSIONS) + 1, 0);
+                       sizeof(struct rte_cryptodev_sym_session *) *
+                       (MAX_NB_SESSIONS + 1), 0);
 
        /* Create multiple crypto sessions*/
        for (i = 0; i < MAX_NB_SESSIONS; i++) {
@@ -10794,6 +10794,7 @@ test_multi_session(void)
                }
        }
 
+       sessions[i] = NULL;
        /* Next session create should fail */
        rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
                        sessions[i], &ut_params->auth_xform,