]> git.droids-corp.org - dpdk.git/commitdiff
vdpa/ifc/base: fix null pointer dereference
authorAndy Pei <andy.pei@intel.com>
Wed, 15 Jun 2022 06:23:34 +0000 (14:23 +0800)
committerMaxime Coquelin <maxime.coquelin@redhat.com>
Fri, 17 Jun 2022 13:19:58 +0000 (15:19 +0200)
Fix null pointer dereference reported in coverity scan.

Coverity issue: 378882
Fixes: 5d75517beffe ("vdpa/ifc/base: access block device registers")
Signed-off-by: Andy Pei <andy.pei@intel.com>
Acked-by: Xiao Wang <xiao.w.wang@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/vdpa/ifc/base/ifcvf.c

index dd475a71f1c7b4060a17be47cd34f5c8afb81fe9..0a9f71a96004942e1e4c73deea0e7d7160cac902 100644 (file)
@@ -255,6 +255,10 @@ ifcvf_hw_disable(struct ifcvf_hw *hw)
        u32 ring_state;
 
        cfg = hw->common_cfg;
+       if (!cfg) {
+               DEBUGOUT("common_cfg in HW is NULL.\n");
+               return;
+       }
 
        IFCVF_WRITE_REG16(IFCVF_MSI_NO_VECTOR, &cfg->msix_config);
        for (i = 0; i < hw->nr_vring; i++) {
@@ -262,6 +266,11 @@ ifcvf_hw_disable(struct ifcvf_hw *hw)
                IFCVF_WRITE_REG16(0, &cfg->queue_enable);
                IFCVF_WRITE_REG16(IFCVF_MSI_NO_VECTOR, &cfg->queue_msix_vector);
 
+               if (!hw->lm_cfg) {
+                       DEBUGOUT("live migration cfg in HW is NULL.\n");
+                       continue;
+               }
+
                if (hw->device_type == IFCVF_BLK)
                        ring_state = *(u32 *)(hw->lm_cfg +
                                        IFCVF_LM_RING_STATE_OFFSET +