From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 691B41150 for ; Fri, 3 Feb 2017 09:40:23 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Feb 2017 00:40:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,328,1477983600"; d="scan'208";a="1121571736" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by fmsmga002.fm.intel.com with ESMTP; 03 Feb 2017 00:40:05 -0800 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.173]) by IRSMSX102.ger.corp.intel.com ([169.254.2.230]) with mapi id 14.03.0248.002; Fri, 3 Feb 2017 08:39:01 +0000 From: "De Lara Guarch, Pablo" To: "Mrozowicz, SlawomirX" , "Doherty, Declan" CC: "dev@dpdk.org" , "Mrozowicz, SlawomirX" Thread-Topic: [dpdk-dev] [PATCH] cryptodev: fix segmentation fault Thread-Index: AQHSfe4Oys3AbHmbl0Oxnvhcj2ZW5KFW8tjA Date: Fri, 3 Feb 2017 08:39:00 +0000 Message-ID: References: <1486113475-4622-1-git-send-email-slawomirx.mrozowicz@intel.com> In-Reply-To: <1486113475-4622-1-git-send-email-slawomirx.mrozowicz@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDQxZTU2NmItODUwNy00ZTAxLTkyYmYtZDg0MTdhN2JlMjUzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InhFQjYxdFU3TER4cVJUMm1WMjJGd1o2VENFMW45RFI4cTdMcWhTY0tacE09In0= x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] cryptodev: fix segmentation fault 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: Fri, 03 Feb 2017 08:40:23 -0000 Hi Slawomir, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Slawomir > Mrozowicz > Sent: Friday, February 03, 2017 9:18 AM > To: Doherty, Declan > Cc: dev@dpdk.org; Mrozowicz, SlawomirX > Subject: [dpdk-dev] [PATCH] cryptodev: fix segmentation fault >=20 > This patch fix problem in function rte_cryptodev_devices_get(). > Program received signal SIGSEGV, Segmentation fault. > It also rework the function to use correct types and clean up visibility. Are you fixing any Coverity issues with this patch? If so, state it here. >=20 > Fixes: 38227c0e3ad2 ("cryptodev: retrieve device info") >=20 > Signed-off-by: Slawomir Mrozowicz > --- > lib/librte_cryptodev/rte_cryptodev.c | 35 +++++++++++++++---------------= ---- > - > lib/librte_cryptodev/rte_cryptodev.h | 4 ++-- > 2 files changed, 17 insertions(+), 22 deletions(-) >=20 > diff --git a/lib/librte_cryptodev/rte_cryptodev.c > b/lib/librte_cryptodev/rte_cryptodev.c > index e557e77..10a59ba 100644 > --- a/lib/librte_cryptodev/rte_cryptodev.c > +++ b/lib/librte_cryptodev/rte_cryptodev.c > @@ -482,34 +482,29 @@ rte_cryptodev_count_devtype(enum > rte_cryptodev_type type) > return dev_count; > } >=20 > -int > +uint8_t > rte_cryptodev_devices_get(const char *dev_name, uint8_t *devices, > - uint8_t nb_devices) > + const uint8_t nb_devices) I don't think it is necessary to use "const" here. Even if you change it in= the function, the value wouldn't be changed outside. > { > - uint8_t i, cmp, count =3D 0; > - struct rte_cryptodev **devs =3D &rte_cryptodev_globals->devs; > - struct rte_device *dev; > - > - for (i =3D 0; i < rte_cryptodev_globals->max_devs && count < > nb_devices; > - i++) { > + uint8_t i, count =3D 0; > + struct rte_cryptodev *devs =3D rte_cryptodev_globals->devs; > + uint8_t max_devs =3D rte_cryptodev_globals->max_devs; >=20 > - if ((*devs + i) > - && (*devs + i)->attached =3D=3D > - RTE_CRYPTODEV_ATTACHED) > { > + for (i =3D 0; i < max_devs && count < nb_devices; i++) { >=20 > - dev =3D (*devs + i)->device; > + if (devs[i].attached =3D=3D RTE_CRYPTODEV_ATTACHED) { > + const struct rte_cryptodev_driver *drv =3D > devs[i].driver; > + int cmp =3D -1; Is it necessary to initialize this value to -1? cmp is going to be overwrit= ten always. >=20 > - if (dev) > - cmp =3D strncmp(dev->driver->name, > - dev_name, > - strlen(dev_name)); > + if (drv) > + cmp =3D strncmp(drv->pci_drv.driver.name, > + dev_name, > strlen(dev_name)); > else > - cmp =3D strncmp((*devs + i)->data->name, > - dev_name, > - strlen(dev_name)); > + cmp =3D strncmp(devs[i].data->name, > + dev_name, > strlen(dev_name)); >=20 > if (cmp =3D=3D 0) > - devices[count++] =3D (*devs + i)->data- > >dev_id; > + devices[count++] =3D devs[i].data->dev_id; > } > } >=20