From: Anoob Joseph Date: Mon, 12 Nov 2018 18:14:12 +0000 (+0000) Subject: crypto/octeontx: fix null pointer dereferencing X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=accf8ca7b03de24b2b6818b9eda2bf73ce736372;p=dpdk.git crypto/octeontx: fix null pointer dereferencing 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. Coverity Issue: 323486, 323489 Fixes: bfe2ae495ee2 ("crypto/octeontx: add PMD skeleton") Fixes: 0961348fdf52 ("crypto/octeontx: add queue pair functions") Signed-off-by: Anoob Joseph --- diff --git a/drivers/crypto/octeontx/otx_cryptodev.c b/drivers/crypto/octeontx/otx_cryptodev.c index 269f0456bd..b201e0a1b1 100644 --- a/drivers/crypto/octeontx/otx_cryptodev.c +++ b/drivers/crypto/octeontx/otx_cryptodev.c @@ -100,8 +100,8 @@ otx_cpt_pci_remove(struct rte_pci_device *pci_dev) if (rte_eal_process_type() == RTE_PROC_PRIMARY) rte_free(cryptodev->data->dev_private); - cryptodev->device = NULL; cryptodev->device->driver = NULL; + cryptodev->device = NULL; cryptodev->data = NULL; /* free metapool memory */ diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c index 23f9659138..90d0c14b88 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;