Skip to contentSkip to conversation

vdpa/ifc: fix null pointer dereference

PATCH Superseded Andy Pei 1 participant 1 message Jun 15, 2022 virtio core

lore
Share & tools
lore

Andy Pei

author
#0 lore raw

PATCH v2 1/1 vdpa/ifc: fix null pointer dereference

Fix null pointer dereference reported in coverity scan.

Coverity issue: 378882

Fixes 5d75517beffe ("vdpa/ifc/base: access correct register for blk device")
---
 drivers/vdpa/ifc/base/ifcvf.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/vdpa/ifc/base/ifcvf.c +9 -0
index dd475a7..0a9f71a 100644
@@ -255,6 +255,10 @@
 	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_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 +
Signature · 1 line
1.8.3.1