From: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>
To: "Mrozowicz, SlawomirX" <slawomirx.mrozowicz@intel.com>,
"Doherty, Declan" <declan.doherty@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
"Mrozowicz, SlawomirX" <slawomirx.mrozowicz@intel.com>
Subject: Re: [dpdk-dev] [PATCH] cryptodev: fix segmentation fault
Date: Fri, 3 Feb 2017 08:39:00 +0000 [thread overview]
Message-ID: <E115CCD9D858EF4F90C690B0DCB4D897476D3A00@IRSMSX108.ger.corp.intel.com> (raw)
In-Reply-To: <1486113475-4622-1-git-send-email-slawomirx.mrozowicz@intel.com>
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;
> }
> }
>
next prev parent reply other threads:[~2017-02-03 8:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 9:17 Slawomir Mrozowicz
2017-02-03 8:39 ` De Lara Guarch, Pablo [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E115CCD9D858EF4F90C690B0DCB4D897476D3A00@IRSMSX108.ger.corp.intel.com \
--to=pablo.de.lara.guarch@intel.com \
--cc=declan.doherty@intel.com \
--cc=dev@dpdk.org \
--cc=slawomirx.mrozowicz@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).