* [dpdk-dev] [PATCH] cryptodev: fix segmentation fault
@ 2017-02-03 9:17 Slawomir Mrozowicz
2017-02-03 8:39 ` De Lara Guarch, Pablo
2017-02-03 15:55 ` [dpdk-dev] [PATCH v2] " Slawomir Mrozowicz
0 siblings, 2 replies; 7+ messages in thread
From: Slawomir Mrozowicz @ 2017-02-03 9:17 UTC (permalink / raw)
To: declan.doherty; +Cc: dev, Slawomir Mrozowicz
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.
Fixes: 38227c0e3ad2 ("cryptodev: retrieve device info")
Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
---
lib/librte_cryptodev/rte_cryptodev.c | 35 +++++++++++++++--------------------
lib/librte_cryptodev/rte_cryptodev.h | 4 ++--
2 files changed, 17 insertions(+), 22 deletions(-)
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;
}
-int
+uint8_t
rte_cryptodev_devices_get(const char *dev_name, uint8_t *devices,
- uint8_t nb_devices)
+ const 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 = -1;
- 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;
}
}
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 67d0f84..0a49de2 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -432,9 +432,9 @@ 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);
+ const uint8_t nb_devices);
/*
* Return the NUMA socket to which a device is connected
*
--
2.5.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH] cryptodev: fix segmentation fault
2017-02-03 9:17 [dpdk-dev] [PATCH] cryptodev: fix segmentation fault Slawomir Mrozowicz
@ 2017-02-03 8:39 ` De Lara Guarch, Pablo
2017-02-03 15:55 ` [dpdk-dev] [PATCH v2] " Slawomir Mrozowicz
1 sibling, 0 replies; 7+ messages in thread
From: De Lara Guarch, Pablo @ 2017-02-03 8:39 UTC (permalink / raw)
To: Mrozowicz, SlawomirX, Doherty, Declan; +Cc: dev, Mrozowicz, SlawomirX
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
>
> 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.
>
> Fixes: 38227c0e3ad2 ("cryptodev: retrieve device info")
>
> Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
> ---
> lib/librte_cryptodev/rte_cryptodev.c | 35 +++++++++++++++-------------------
> -
> lib/librte_cryptodev/rte_cryptodev.h | 4 ++--
> 2 files changed, 17 insertions(+), 22 deletions(-)
>
> 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;
> }
>
> -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 = 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 = -1;
Is it necessary to initialize this value to -1? cmp is going to be overwritten always.
>
> - 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;
> }
> }
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dpdk-dev] [PATCH v2] cryptodev: fix segmentation fault
2017-02-03 9:17 [dpdk-dev] [PATCH] cryptodev: fix segmentation fault Slawomir Mrozowicz
2017-02-03 8:39 ` De Lara Guarch, Pablo
@ 2017-02-03 15:55 ` Slawomir Mrozowicz
2017-02-03 15:13 ` De Lara Guarch, Pablo
2017-02-09 15:29 ` De Lara Guarch, Pablo
1 sibling, 2 replies; 7+ messages in thread
From: Slawomir Mrozowicz @ 2017-02-03 15:55 UTC (permalink / raw)
To: declan.doherty; +Cc: dev, Slawomir Mrozowicz
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(-)
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index e557e77..a64320e 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;
}
-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;
}
}
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 37f08ae..82f3bc3 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -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);
/*
--
2.5.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH v2] cryptodev: fix segmentation fault
2017-02-03 15:55 ` [dpdk-dev] [PATCH v2] " Slawomir Mrozowicz
@ 2017-02-03 15:13 ` De Lara Guarch, Pablo
2017-02-09 15:29 ` De Lara Guarch, Pablo
1 sibling, 0 replies; 7+ messages in thread
From: De Lara Guarch, Pablo @ 2017-02-03 15:13 UTC (permalink / raw)
To: Mrozowicz, SlawomirX, Doherty, Declan; +Cc: dev, Mrozowicz, SlawomirX
> -----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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH v2] cryptodev: fix segmentation fault
2017-02-03 15:55 ` [dpdk-dev] [PATCH v2] " Slawomir Mrozowicz
2017-02-03 15:13 ` De Lara Guarch, Pablo
@ 2017-02-09 15:29 ` De Lara Guarch, Pablo
2017-02-09 22:21 ` De Lara Guarch, Pablo
1 sibling, 1 reply; 7+ messages in thread
From: De Lara Guarch, Pablo @ 2017-02-09 15:29 UTC (permalink / raw)
To: Mrozowicz, SlawomirX, Doherty, Declan; +Cc: dev, Mrozowicz, SlawomirX
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH v2] cryptodev: fix segmentation fault
2017-02-09 15:29 ` De Lara Guarch, Pablo
@ 2017-02-09 22:21 ` De Lara Guarch, Pablo
2017-02-10 12:53 ` Mrozowicz, SlawomirX
0 siblings, 1 reply; 7+ messages in thread
From: De Lara Guarch, Pablo @ 2017-02-09 22:21 UTC (permalink / raw)
To: De Lara Guarch, Pablo, Mrozowicz, SlawomirX, Doherty, Declan
Cc: dev, Mrozowicz, SlawomirX
> -----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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH v2] cryptodev: fix segmentation fault
2017-02-09 22:21 ` De Lara Guarch, Pablo
@ 2017-02-10 12:53 ` Mrozowicz, SlawomirX
0 siblings, 0 replies; 7+ messages in thread
From: Mrozowicz, SlawomirX @ 2017-02-10 12:53 UTC (permalink / raw)
To: De Lara Guarch, Pablo, Doherty, Declan; +Cc: dev
>-----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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-02-10 12:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-03 9:17 [dpdk-dev] [PATCH] cryptodev: fix segmentation fault Slawomir Mrozowicz
2017-02-03 8:39 ` De Lara Guarch, Pablo
2017-02-03 15:55 ` [dpdk-dev] [PATCH v2] " Slawomir Mrozowicz
2017-02-03 15:13 ` De Lara Guarch, Pablo
2017-02-09 15:29 ` De Lara Guarch, Pablo
2017-02-09 22:21 ` De Lara Guarch, Pablo
2017-02-10 12:53 ` Mrozowicz, SlawomirX
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).