[3/3] crypto/octeontx: fix null pointer dereferencing

Message ID 1541949837-9629-4-git-send-email-anoob.joseph@caviumnetworks.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series fixing coverity reported issues |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK

Commit Message

Anoob Joseph Nov. 11, 2018, 3:24 p.m. UTC
  The function otx_cpt_get_resource() would be setting the pointer
'instance'. In case of error, 'instance' would be set to NULL, and
returns rte_errno. If rte_errno when 'instance' is set to NULL, it can
lead to NULL pointer dereferencing.

Fixes: 0961348fdf52 ("crypto/octeontx: add queue pair functions")

Signed-off-by: Anoob Joseph <anoob.joseph@caviumnetworks.com>
---
 drivers/crypto/octeontx/otx_cryptodev_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c
index 23f9659..90d0c14 100644
--- a/drivers/crypto/octeontx/otx_cryptodev_ops.c
+++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c
@@ -216,7 +216,7 @@  otx_cpt_que_pair_setup(struct rte_cryptodev *dev,
 	}
 
 	ret = otx_cpt_get_resource(cptvf, 0, &instance);
-	if (ret != 0) {
+	if (ret != 0 || instance == NULL) {
 		CPT_LOG_ERR("Error getting instance handle from device %s : "
 			    "ret = %d", dev->data->name, ret);
 		return ret;