[dpdk-dev] cryptodev: fix for loop in rte_cryptodev_pmd_get_named_dev

Message ID 1484143787-8336-1-git-send-email-roy.fan.zhang@intel.com
State Accepted, archived
Delegated to: Pablo de Lara Guarch
Headers show

Checks

Context Check Description
ci/Intel compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Zhang, Roy Fan Jan. 11, 2017, 2:09 p.m.
Fixes: d11b0f30 ("cryptodev: introduce API and framework for crypto devices")

This patch fixes the dev value update problem in
rte_cryptodev_pmd_get_named_dev, orginally, dev won't be updated
after the initiail step in the loop.

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 lib/librte_cryptodev/rte_cryptodev_pmd.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Trahe, Fiona Jan. 11, 2017, 2:29 p.m. | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Fan Zhang
> Sent: Wednesday, January 11, 2017 2:10 PM
> To: dev@dpdk.org
> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Subject: [dpdk-dev] [PATCH] cryptodev: fix for loop in
> rte_cryptodev_pmd_get_named_dev
> 
> Fixes: d11b0f30 ("cryptodev: introduce API and framework for crypto
> devices")
> 
> This patch fixes the dev value update problem in
> rte_cryptodev_pmd_get_named_dev, orginally, dev won't be updated
> after the initiail step in the loop.
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
De Lara Guarch, Pablo Jan. 11, 2017, 2:57 p.m. | #2
> -----Original Message-----
> From: Trahe, Fiona
> Sent: Wednesday, January 11, 2017 2:29 PM
> To: Zhang, Roy Fan; dev@dpdk.org
> Cc: De Lara Guarch, Pablo
> Subject: RE: [dpdk-dev] [PATCH] cryptodev: fix for loop in
> rte_cryptodev_pmd_get_named_dev
> 
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Fan Zhang
> > Sent: Wednesday, January 11, 2017 2:10 PM
> > To: dev@dpdk.org
> > Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> > Subject: [dpdk-dev] [PATCH] cryptodev: fix for loop in
> > rte_cryptodev_pmd_get_named_dev
> >
> > Fixes: d11b0f30 ("cryptodev: introduce API and framework for crypto
> > devices")
> >
> > This patch fixes the dev value update problem in
> > rte_cryptodev_pmd_get_named_dev, orginally, dev won't be updated
> > after the initiail step in the loop.
> >
> > Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> Acked-by: Fiona Trahe <fiona.trahe@intel.com>

CC'ing stable@dpdk.org.

Applied to dpdk-next-crypto.
Thanks,

Pablo

Patch

diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index abfe2dc..c6a5794 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -183,8 +183,9 @@  rte_cryptodev_pmd_get_named_dev(const char *name)
 	if (name == NULL)
 		return NULL;
 
-	for (i = 0, dev = &rte_cryptodev_globals->devs[i];
-			i < rte_cryptodev_globals->max_devs; i++) {
+	for (i = 0; i < rte_cryptodev_globals->max_devs; i++) {
+		dev = &rte_cryptodev_globals->devs[i];
+
 		if ((dev->attached == RTE_CRYPTODEV_ATTACHED) &&
 				(strcmp(dev->data->name, name) == 0))
 			return dev;