From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 3AEBC282 for ; Thu, 9 Feb 2017 23:55:18 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 09 Feb 2017 14:55:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,138,1484035200"; d="scan'208";a="1124503755" Received: from irsmsx152.ger.corp.intel.com ([163.33.192.66]) by fmsmga002.fm.intel.com with ESMTP; 09 Feb 2017 14:55:17 -0800 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.173]) by IRSMSX152.ger.corp.intel.com ([169.254.6.191]) with mapi id 14.03.0248.002; Thu, 9 Feb 2017 22:55:16 +0000 From: "De Lara Guarch, Pablo" To: "Gajewski, AleksanderX" , "Doherty, Declan" CC: "dev@dpdk.org" , "Gajewski, AleksanderX" Thread-Topic: [dpdk-dev] [PATCH] app/test-crypto-perf: fix uninitialized scalar variable Thread-Index: AQHSgSN/m8M4AE4ERUG3FiSphx7NnKFhSxKA Date: Thu, 9 Feb 2017 22:55:15 +0000 Message-ID: References: <1486459306-11496-1-git-send-email-aleksanderx.gajewski@intel.com> In-Reply-To: <1486459306-11496-1-git-send-email-aleksanderx.gajewski@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOWI4NmZmZDgtNzlhNS00ZGZiLTg3NzAtNGE0YzEzOGYxYWVhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IjBPWXJGdkZHMVlhcEVNaEhQMUdabzJGRUk5UW9IdW9xWmVBV1puY3p2Wlk9In0= x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] app/test-crypto-perf: fix uninitialized scalar variable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Feb 2017 22:55:19 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Aleksander > Gajewski > Sent: Tuesday, February 07, 2017 9:22 AM > To: Doherty, Declan > Cc: dev@dpdk.org; Gajewski, AleksanderX > Subject: [dpdk-dev] [PATCH] app/test-crypto-perf: fix uninitialized scala= r > variable >=20 > Fix problem with uninitialized nb_cryptodevs variable by > initialize it with 0 value. Program could jump to err label > without running cperf_initialize_cryptodev() function. >=20 > Coverity issue: 141073 > Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test > application") >=20 > Signed-off-by: Aleksander Gajewski > --- > app/test-crypto-perf/main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c > index 6c128d8..035021a 100644 > --- a/app/test-crypto-perf/main.c > +++ b/app/test-crypto-perf/main.c > @@ -264,7 +264,7 @@ >=20 > void *ctx[RTE_MAX_LCORE] =3D { }; >=20 > - int nb_cryptodevs; > + int nb_cryptodevs =3D 0; > uint8_t cdev_id, i; > uint8_t enabled_cdevs[RTE_CRYPTO_MAX_DEVS] =3D { 0 }; >=20 > -- > 1.9.1 Actually, this fix is incomplete. In a few lines below, we have these lines: nb_cryptodevs =3D cperf_initialize_cryptodev(&opts, enabled_cdevs); if (nb_cryptodevs < 1) { RTE_LOG(ERR, USER1, "Failed to initialise requested crypto = " "device type\n"); goto err; } If cperf_initialize_cryptodev() returns -EINVAL, then, nb_cryptodevs will b= e negative, which shouldn't be when going to err label. I think "nb_cryptodevs =3D 0 " is necessary inside this conditional, before= jumping to err. Thanks, Pablo