From: Andy Pei Date: Wed, 15 Jun 2022 06:23:34 +0000 (+0800) Subject: vdpa/ifc/base: fix null pointer dereference X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4a8ca6590d30984fef7b25e31c9d36c07afa761d;p=dpdk.git vdpa/ifc/base: fix null pointer dereference 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 Acked-by: Xiao Wang Reviewed-by: Maxime Coquelin --- diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c index dd475a71f1..0a9f71a960 100644 --- a/drivers/vdpa/ifc/base/ifcvf.c +++ b/drivers/vdpa/ifc/base/ifcvf.c @@ -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 +