DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] test/crypto: fix gcc 11 array-bounds error
@ 2021-05-05  8:53 Kevin Traynor
  2021-05-17 19:24 ` [dpdk-dev] [EXT] " Akhil Goyal
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Traynor @ 2021-05-05  8:53 UTC (permalink / raw)
  To: dev
  Cc: Kevin Traynor, stable, Declan Doherty, Sergio Gonzalez Monroy,
	John Griffin, Des O Dea, Fiona Trahe

$ gcc --version
gcc (GCC) 11.1.1 20210428 (Red Hat 11.1.1-1)

/test_cryptodev.c.o -c ../app/test/test_cryptodev.c
../app/test/test_cryptodev.c: In function ‘test_multi_session’:
../app/test/test_cryptodev.c:10447:9:
error: array subscript ‘struct rte_cryptodev_sym_session *[4]’
is partly outside array bounds of ‘unsigned char[33]’
[-Werror=array-bounds]
10447 |   rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10448 |     sessions[i], &ut_params->auth_xform,
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10449 |     ts_params->session_priv_mpool);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../app/test/test_cryptodev.c:10399:20:
note: referencing an object of size 33 allocated by ‘rte_malloc’
10399 |  sessions = rte_malloc(NULL,
      |             ^~~~~~~~~~~~~~~~
10400 |             (sizeof(struct rte_cryptodev_sym_session *) *
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10401 |             MAX_NB_SESSIONS) + 1, 0);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~

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>
---
 app/test/test_cryptodev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 32e64e2dd1..4f766e070d 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -10398,6 +10398,6 @@ test_multi_session(void)
 
 	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*/
@@ -10444,4 +10444,5 @@ test_multi_session(void)
 	}
 
+	sessions[i] = NULL;
 	/* Next session create should fail */
 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
-- 
2.30.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [EXT] [PATCH] test/crypto: fix gcc 11 array-bounds error
  2021-05-05  8:53 [dpdk-dev] [PATCH] test/crypto: fix gcc 11 array-bounds error Kevin Traynor
@ 2021-05-17 19:24 ` Akhil Goyal
  0 siblings, 0 replies; 2+ messages in thread
From: Akhil Goyal @ 2021-05-17 19:24 UTC (permalink / raw)
  To: Kevin Traynor, dev
  Cc: stable, Declan Doherty, Sergio Gonzalez Monroy, John Griffin,
	Des O Dea, Fiona Trahe

> $ gcc --version
> gcc (GCC) 11.1.1 20210428 (Red Hat 11.1.1-1)
> 
> /test_cryptodev.c.o -c ../app/test/test_cryptodev.c
> ../app/test/test_cryptodev.c: In function ‘test_multi_session’:
> ../app/test/test_cryptodev.c:10447:9:
> error: array subscript ‘struct rte_cryptodev_sym_session *[4]’
> is partly outside array bounds of ‘unsigned char[33]’
> [-Werror=array-bounds]
> 10447 |   rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
>       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 10448 |     sessions[i], &ut_params->auth_xform,
>       |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 10449 |     ts_params->session_priv_mpool);
>       |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../app/test/test_cryptodev.c:10399:20:
> note: referencing an object of size 33 allocated by ‘rte_malloc’
> 10399 |  sessions = rte_malloc(NULL,
>       |             ^~~~~~~~~~~~~~~~
> 10400 |             (sizeof(struct rte_cryptodev_sym_session *) *
>       |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 10401 |             MAX_NB_SESSIONS) + 1, 0);
>       |             ~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 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>

Applied to dpdk-next-crypto

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-17 19:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05  8:53 [dpdk-dev] [PATCH] test/crypto: fix gcc 11 array-bounds error Kevin Traynor
2021-05-17 19:24 ` [dpdk-dev] [EXT] " Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).