[dpdk-dev,v2] cryptodev: fix segmentation fault
Checks
Commit Message
This patch fix problem in function rte_cryptodev_devices_get().
Program received signal SIGSEGV, Segmentation fault.
It rework the function to use correct types and clean up visibility.
It also fix Coverity ID 141073
Fixes: 38227c0e3ad2 ("cryptodev: retrieve device info")
Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
---
lib/librte_cryptodev/rte_cryptodev.c | 33 ++++++++++++++-------------------
lib/librte_cryptodev/rte_cryptodev.h | 2 +-
2 files changed, 15 insertions(+), 20 deletions(-)
Comments
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Slawomir
> Mrozowicz
> Sent: Friday, February 03, 2017 3:55 PM
> To: Doherty, Declan
> Cc: dev@dpdk.org; Mrozowicz, SlawomirX
> Subject: [dpdk-dev] [PATCH v2] cryptodev: fix segmentation fault
>
> This patch fix problem in function rte_cryptodev_devices_get().
> Program received signal SIGSEGV, Segmentation fault.
> It rework the function to use correct types and clean up visibility.
> It also fix Coverity ID 141073
Better to use our current format for Coverity issues:
Coverity issue: 141073
>
> Fixes: 38227c0e3ad2 ("cryptodev: retrieve device info")
>
> Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
Apart from comment above:
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Hi Slawomir,
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Slawomir
> Mrozowicz
> Sent: Friday, February 03, 2017 3:55 PM
> To: Doherty, Declan
> Cc: dev@dpdk.org; Mrozowicz, SlawomirX
> Subject: [dpdk-dev] [PATCH v2] cryptodev: fix segmentation fault
>
> This patch fix problem in function rte_cryptodev_devices_get().
> Program received signal SIGSEGV, Segmentation fault.
> It rework the function to use correct types and clean up visibility.
> It also fix Coverity ID 141073
>
> Fixes: 38227c0e3ad2 ("cryptodev: retrieve device info")
>
> Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
I think this patch fixes coverity issue 141067, not 141073.
Could you submit a v3 for this patch? Make sure to follow the format:
Coverity issue: XXXXXX
Thanks,
Pablo
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of De Lara Guarch,
> Pablo
> Sent: Thursday, February 09, 2017 3:29 PM
> To: Mrozowicz, SlawomirX; Doherty, Declan
> Cc: dev@dpdk.org; Mrozowicz, SlawomirX
> Subject: Re: [dpdk-dev] [PATCH v2] cryptodev: fix segmentation fault
>
> Hi Slawomir,
>
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Slawomir
> > Mrozowicz
> > Sent: Friday, February 03, 2017 3:55 PM
> > To: Doherty, Declan
> > Cc: dev@dpdk.org; Mrozowicz, SlawomirX
> > Subject: [dpdk-dev] [PATCH v2] cryptodev: fix segmentation fault
> >
> > This patch fix problem in function rte_cryptodev_devices_get().
> > Program received signal SIGSEGV, Segmentation fault.
> > It rework the function to use correct types and clean up visibility.
> > It also fix Coverity ID 141073
> >
> > Fixes: 38227c0e3ad2 ("cryptodev: retrieve device info")
> >
> > Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
>
> I think this patch fixes coverity issue 141067, not 141073.
> Could you submit a v3 for this patch? Make sure to follow the format:
I have done it for you.
Applied to dpdk-next-crypto.
Thanks,
Pablo
>-----Original Message-----
>From: De Lara Guarch, Pablo
>Sent: Thursday, February 9, 2017 11:21 PM
>To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>; Mrozowicz,
>SlawomirX <slawomirx.mrozowicz@intel.com>; Doherty, Declan
><declan.doherty@intel.com>
>Cc: dev@dpdk.org; Mrozowicz, SlawomirX <slawomirx.mrozowicz@intel.com>
>Subject: RE: [dpdk-dev] [PATCH v2] cryptodev: fix segmentation fault
>
>
>
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of De Lara Guarch,
>> Pablo
>> Sent: Thursday, February 09, 2017 3:29 PM
>> To: Mrozowicz, SlawomirX; Doherty, Declan
>> Cc: dev@dpdk.org; Mrozowicz, SlawomirX
>> Subject: Re: [dpdk-dev] [PATCH v2] cryptodev: fix segmentation fault
>>
>> Hi Slawomir,
>>
>> > -----Original Message-----
>> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Slawomir
>> > Mrozowicz
>> > Sent: Friday, February 03, 2017 3:55 PM
>> > To: Doherty, Declan
>> > Cc: dev@dpdk.org; Mrozowicz, SlawomirX
>> > Subject: [dpdk-dev] [PATCH v2] cryptodev: fix segmentation fault
>> >
>> > This patch fix problem in function rte_cryptodev_devices_get().
>> > Program received signal SIGSEGV, Segmentation fault.
>> > It rework the function to use correct types and clean up visibility.
>> > It also fix Coverity ID 141073
>> >
>> > Fixes: 38227c0e3ad2 ("cryptodev: retrieve device info")
>> >
>> > Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
>>
>> I think this patch fixes coverity issue 141067, not 141073.
>> Could you submit a v3 for this patch? Make sure to follow the format:
>
>I have done it for you.
>
>Applied to dpdk-next-crypto.
>Thanks,
>
>Pablo
Thanks Pablo.
Sławomir
@@ -482,34 +482,29 @@ rte_cryptodev_count_devtype(enum rte_cryptodev_type type)
return dev_count;
}
-int
+uint8_t
rte_cryptodev_devices_get(const char *dev_name, uint8_t *devices,
uint8_t nb_devices)
{
- uint8_t i, cmp, count = 0;
- struct rte_cryptodev **devs = &rte_cryptodev_globals->devs;
- struct rte_device *dev;
-
- for (i = 0; i < rte_cryptodev_globals->max_devs && count < nb_devices;
- i++) {
+ uint8_t i, count = 0;
+ struct rte_cryptodev *devs = rte_cryptodev_globals->devs;
+ uint8_t max_devs = rte_cryptodev_globals->max_devs;
- if ((*devs + i)
- && (*devs + i)->attached ==
- RTE_CRYPTODEV_ATTACHED) {
+ for (i = 0; i < max_devs && count < nb_devices; i++) {
- dev = (*devs + i)->device;
+ if (devs[i].attached == RTE_CRYPTODEV_ATTACHED) {
+ const struct rte_cryptodev_driver *drv = devs[i].driver;
+ int cmp;
- if (dev)
- cmp = strncmp(dev->driver->name,
- dev_name,
- strlen(dev_name));
+ if (drv)
+ cmp = strncmp(drv->pci_drv.driver.name,
+ dev_name, strlen(dev_name));
else
- cmp = strncmp((*devs + i)->data->name,
- dev_name,
- strlen(dev_name));
+ cmp = strncmp(devs[i].data->name,
+ dev_name, strlen(dev_name));
if (cmp == 0)
- devices[count++] = (*devs + i)->data->dev_id;
+ devices[count++] = devs[i].data->dev_id;
}
}
@@ -435,7 +435,7 @@ rte_cryptodev_count_devtype(enum rte_cryptodev_type type);
* @return
* Returns number of attached crypto device.
*/
-int
+uint8_t
rte_cryptodev_devices_get(const char *dev_name, uint8_t *devices,
uint8_t nb_devices);
/*