git: c0a4a7bb942f - main - qat: Fixed Coverity reported issue

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 01 Feb 2023 16:02:15 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=c0a4a7bb942fd3302f0093e4353820916d3661d1

commit c0a4a7bb942fd3302f0093e4353820916d3661d1
Author:     Krzysztof Zdziarski <krzysztofx.zdziarski@intel.com>
AuthorDate: 2023-02-01 15:06:11 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-02-01 16:02:08 +0000

    qat: Fixed Coverity reported issue
    
    This patch provides fixes for following Coverity issues:
    CID 1504073
    CID 1504075
    CID 1504076
    CID 1504077
    
    Patch co-authored by: Krzysztof Zdziarski <krzysztofx.zdziarski@intel.com>
    Patch co-authored by: Michal Gulbicki <michalx.gulbicki@intel.com>
    Patch co-authored by: Julian Grajkowski <julianx.grajkowski@intel.com>
    Patch co-authored by: Piotr Kasierski <piotrx.kasierski@intel.com>
    Patch co-authored by: Lukasz Kolodzinski <lukaszx.kolodzinski@intel.com>
    Patch co-authored by: Karol Grzadziel <karolx.grzadziel@intel.com>
    
    Fixes:          a977168c48d4 ("qat: Add IntelĀ® 4xxx Series platform support")
    Reviewed by:    markj
    Sponsored by:   Intel Corporation
    Differential Revision: https://reviews.freebsd.org/D38339
---
 sys/dev/qat/qat_api/common/compression/dc_datapath.c | 14 ++++++--------
 sys/dev/qat/qat_common/adf_hw_arbiter.c              |  3 ++-
 sys/dev/qat/qat_hw/qat_4xxx/adf_4xxx_hw_data.c       |  2 +-
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/sys/dev/qat/qat_api/common/compression/dc_datapath.c b/sys/dev/qat/qat_api/common/compression/dc_datapath.c
index 2e1f9ff96bd8..526954e15227 100644
--- a/sys/dev/qat/qat_api/common/compression/dc_datapath.c
+++ b/sys/dev/qat/qat_api/common/compression/dc_datapath.c
@@ -152,6 +152,7 @@ dcCompression_ProcessCallback(void *pRespMsg)
 
 	if (NULL != pOpData) {
 		verifyHwIntegrityCrcs = pOpData->verifyHwIntegrityCrcs;
+		integrityCrcCheck = pOpData->integrityCrcCheck;
 	}
 
 	hdrFlags = pCompRespMsg->comn_resp.hdr_flags;
@@ -175,10 +176,9 @@ dcCompression_ProcessCallback(void *pRespMsg)
 			(pService->pDcDpCb)(pResponse);
 		} else {
 			/* Free the memory pool */
-			if (NULL != pCookie) {
-				Lac_MemPoolEntryFree(pCookie);
-				pCookie = NULL;
-			}
+			Lac_MemPoolEntryFree(pCookie);
+			pCookie = NULL;
+
 			if (NULL != pCbFunc) {
 				pCbFunc(callbackTag, status);
 			}
@@ -432,10 +432,8 @@ dcCompression_ProcessCallback(void *pRespMsg)
 		}
 
 		/* Free the memory pool */
-		if (NULL != pCookie) {
-			Lac_MemPoolEntryFree(pCookie);
-			pCookie = NULL;
-		}
+		Lac_MemPoolEntryFree(pCookie);
+		pCookie = NULL;
 
 		if (NULL != pCbFunc) {
 			pCbFunc(callbackTag, status);
diff --git a/sys/dev/qat/qat_common/adf_hw_arbiter.c b/sys/dev/qat/qat_common/adf_hw_arbiter.c
index e89a5f6ce68c..827d612e2c22 100644
--- a/sys/dev/qat/qat_common/adf_hw_arbiter.c
+++ b/sys/dev/qat/qat_common/adf_hw_arbiter.c
@@ -193,7 +193,7 @@ adf_exit_arb(struct adf_accel_dev *accel_dev)
 void
 adf_disable_arb(struct adf_accel_dev *accel_dev)
 {
-	struct adf_hw_csr_ops *csr_ops = GET_CSR_OPS(accel_dev);
+	struct adf_hw_csr_ops *csr_ops;
 	struct resource *csr;
 	unsigned int i;
 
@@ -201,6 +201,7 @@ adf_disable_arb(struct adf_accel_dev *accel_dev)
 		return;
 
 	csr = accel_dev->transport->banks[0].csr_addr;
+	csr_ops = GET_CSR_OPS(accel_dev);
 
 	/* Disable arbitration on all rings */
 	for (i = 0; i < GET_MAX_BANKS(accel_dev); i++)
diff --git a/sys/dev/qat/qat_hw/qat_4xxx/adf_4xxx_hw_data.c b/sys/dev/qat/qat_hw/qat_4xxx/adf_4xxx_hw_data.c
index 1c8c9a2fda4c..002ea6d5d876 100644
--- a/sys/dev/qat/qat_hw/qat_4xxx/adf_4xxx_hw_data.c
+++ b/sys/dev/qat/qat_hw/qat_4xxx/adf_4xxx_hw_data.c
@@ -747,7 +747,7 @@ static bool
 check_accel_unit_service(enum adf_accel_unit_services au_srv,
 			 enum adf_cfg_service_type ring_srv)
 {
-	if ((au_srv & ADF_ACCEL_SERVICE_NULL) && ring_srv == NA)
+	if ((ADF_ACCEL_SERVICE_NULL == au_srv) && ring_srv == NA)
 		return true;
 	if ((au_srv & ADF_ACCEL_COMPRESSION) && ring_srv == COMP)
 		return true;