[v1,3/3] cryptodev: fix uninitialized session clear

Message ID 20190411141656.27720-3-marko.kovacevic@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series [v1,1/3] examples/fips: fix hmac test failure |

Checks

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

Commit Message

Kovacevic, Marko April 11, 2019, 2:16 p.m. UTC
  added check to see if a session for a device
has been initialised if it has return 0.

Fixes: 5d6c73dd5938 ("cryptodev: add reference count to session private data")
Cc: roy.fan.zhang@intel.com
Cc: stable@dpdk.org

Signed-off-by: Marko Kovacevic <marko.kovacevic@intel.com>
---
 lib/librte_cryptodev/rte_cryptodev.c | 2 ++
 1 file changed, 2 insertions(+)
  

Patch

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 2675e1ef7..00c2cf432 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1386,6 +1386,8 @@  rte_cryptodev_sym_session_clear(uint8_t dev_id,
 		return -EINVAL;
 
 	driver_id = dev->driver_id;
+	if (sess->sess_data[driver_id].refcnt == 0)
+		return 0;
 	if (--sess->sess_data[driver_id].refcnt != 0)
 		return -EBUSY;