From patchwork Wed May 5 08:53:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kevin Traynor X-Patchwork-Id: 92892 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 93E55A0524; Wed, 5 May 2021 10:53:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7951540040; Wed, 5 May 2021 10:53:46 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 6F4024003C for ; Wed, 5 May 2021 10:53:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620204824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=r+9kmVbabnpkW5DZAFS1voBBms0FoUIizOA2opP6ITM=; b=dnKzBUVhbQipw5fFdqkWAS5VfIoYyj7f+TcO/J6mkO3e+ME/8ncFyn03h5Rs1LOBp9c5gR +gdlXiq/F0dQpDR0QF8H9aK3POqJno2mijKlUxdgcWdhLD+DRZWDKZhxJzrbBPJm7YTKGR LvUObbVrIAYc12CbkFcLhghVPQr7A4E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-120-R8okU3IxMEG45P27amuBEQ-1; Wed, 05 May 2021 04:53:42 -0400 X-MC-Unique: R8okU3IxMEG45P27amuBEQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D7E536D249; Wed, 5 May 2021 08:53:40 +0000 (UTC) Received: from rh.redhat.com (ovpn-115-141.ams2.redhat.com [10.36.115.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2FB45D6D3; Wed, 5 May 2021 08:53:38 +0000 (UTC) From: Kevin Traynor To: dev@dpdk.org Cc: Kevin Traynor , stable@dpdk.org, Declan Doherty , Sergio Gonzalez Monroy , John Griffin , Des O Dea , Fiona Trahe Date: Wed, 5 May 2021 09:53:14 +0100 Message-Id: <20210505085314.54750-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ktraynor@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH] test/crypto: fix gcc 11 array-bounds error X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" $ 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 Acked-by: Akhil Goyal --- 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],