common/qat: fix null dereference in release function
Checks
Commit Message
This commit fixes NULL dereference in the release function,
and three additional coverity issues related to NULL check.
Coverity issue: 415038
Coverity issue: 415050
Coverity issue: 415052
Coverity issue: 415053
Fixes: 477d7d051211 ("common/qat: decouple drivers from common code")
Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
---
drivers/common/qat/qat_device.c | 14 +++++++-------
drivers/compress/qat/qat_comp_pmd.c | 6 ++++--
drivers/crypto/qat/qat_asym.c | 5 ++---
drivers/crypto/qat/qat_sym.c | 4 ++--
4 files changed, 15 insertions(+), 14 deletions(-)
Comments
> -----Original Message-----
> From: Kusztal, ArkadiuszX <arkadiuszx.kusztal@intel.com>
> Sent: Friday, March 8, 2024 9:44 AM
> To: dev@dpdk.org
> Cc: gakhil@marvell.com; Power, Ciara <ciara.power@intel.com>; Kusztal,
> ArkadiuszX <arkadiuszx.kusztal@intel.com>
> Subject: [PATCH] common/qat: fix null dereference in release function
>
> This commit fixes NULL dereference in the release function, and three additional
> coverity issues related to NULL check.
>
> Coverity issue: 415038
> Coverity issue: 415050
> Coverity issue: 415052
> Coverity issue: 415053
> Fixes: 477d7d051211 ("common/qat: decouple drivers from common code")
>
> Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
> ---
> drivers/common/qat/qat_device.c | 14 +++++++-------
> drivers/compress/qat/qat_comp_pmd.c | 6 ++++--
> drivers/crypto/qat/qat_asym.c | 5 ++---
> drivers/crypto/qat/qat_sym.c | 4 ++--
> 4 files changed, 15 insertions(+), 14 deletions(-)
>
Acked-by: Ciara Power <ciara.power@intel.com>
> > Subject: [PATCH] common/qat: fix null dereference in release function
> >
> > This commit fixes NULL dereference in the release function, and three
> additional
> > coverity issues related to NULL check.
> >
> > Coverity issue: 415038
> > Coverity issue: 415050
> > Coverity issue: 415052
> > Coverity issue: 415053
> > Fixes: 477d7d051211 ("common/qat: decouple drivers from common code")
> >
> > Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
> > ---
> > drivers/common/qat/qat_device.c | 14 +++++++-------
> > drivers/compress/qat/qat_comp_pmd.c | 6 ++++--
> > drivers/crypto/qat/qat_asym.c | 5 ++---
> > drivers/crypto/qat/qat_sym.c | 4 ++--
> > 4 files changed, 15 insertions(+), 14 deletions(-)
> >
>
> Acked-by: Ciara Power <ciara.power@intel.com>
Applied to dpdk-next-crypto
Thanks.
@@ -420,15 +420,15 @@ qat_pci_device_release(struct rte_pci_device *pci_dev)
if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
for (i = 0; i < QAT_MAX_SERVICES; i++) {
- if (qat_dev->pmd[i] == NULL)
- continue;
- QAT_LOG(DEBUG, "QAT %s device %s is busy",
- qat_service[i].name, name);
- busy = 1;
+ if (qat_dev->pmd[i] != NULL) {
+ QAT_LOG(DEBUG, "QAT %s device %s is busy",
+ qat_service[i].name, name);
+ busy = 1;
+ }
+ }
if (busy)
return -EBUSY;
rte_memzone_free(inst->mz);
- }
}
memset(inst, 0, sizeof(struct qat_device_info));
qat_nb_pci_devices--;
@@ -445,7 +445,7 @@ qat_pci_dev_destroy(struct qat_pci_device *qat_pci_dev,
int i;
for (i = 0; i < QAT_MAX_SERVICES; i++) {
- if (!qat_service[i].dev_create)
+ if (!qat_service[i].dev_destroy)
continue;
qat_service[i].dev_destroy(qat_pci_dev);
}
@@ -792,12 +792,14 @@ qat_comp_dev_create(struct qat_pci_device *qat_pci_dev)
static int
qat_comp_dev_destroy(struct qat_pci_device *qat_pci_dev)
{
- struct qat_comp_dev_private *dev =
- qat_pci_dev->pmd[QAT_SERVICE_COMPRESSION];
+ struct qat_comp_dev_private *dev;
if (qat_pci_dev == NULL)
return -ENODEV;
+ dev = qat_pci_dev->pmd[QAT_SERVICE_COMPRESSION];
+ if (dev == NULL)
+ return 0;
if (rte_eal_process_type() == RTE_PROC_PRIMARY)
rte_memzone_free(dev->capa_mz);
@@ -1625,16 +1625,15 @@ static int
qat_asym_dev_destroy(struct qat_pci_device *qat_pci_dev)
{
struct rte_cryptodev *cryptodev;
- struct qat_cryptodev_private *dev =
- qat_pci_dev->pmd[QAT_SERVICE_ASYMMETRIC];
+ struct qat_cryptodev_private *dev;
if (qat_pci_dev == NULL)
return -ENODEV;
+ dev = qat_pci_dev->pmd[QAT_SERVICE_ASYMMETRIC];
if (dev == NULL)
return 0;
if (rte_eal_process_type() == RTE_PROC_PRIMARY)
rte_memzone_free(dev->capa_mz);
-
/* free crypto device */
cryptodev = rte_cryptodev_pmd_get_dev(dev->dev_id);
rte_cryptodev_pmd_destroy(cryptodev);
@@ -345,11 +345,11 @@ static int
qat_sym_dev_destroy(struct qat_pci_device *qat_pci_dev)
{
struct rte_cryptodev *cryptodev;
- struct qat_cryptodev_private *dev =
- qat_pci_dev->pmd[QAT_SERVICE_SYMMETRIC];
+ struct qat_cryptodev_private *dev;
if (qat_pci_dev == NULL)
return -ENODEV;
+ dev = qat_pci_dev->pmd[QAT_SERVICE_SYMMETRIC];
if (dev == NULL)
return 0;
if (rte_eal_process_type() == RTE_PROC_PRIMARY)