[PATCH] vdpa/sfc: fix null pointer dereference

Weiguo Li liwg06 at foxmail.com
Sat Jan 29 18:30:12 CET 2022


When sva is null, sfc_vdpa_info(sva, ...) will cause a null
dereference. Use SFC_VDPA_GENERIC_LOG() to avoid that.
See macros sfc_vdpa_info and SFC_VDPA_GENERIC_LOG
defined in drivers/vdpa/sfc/sfc_vdpa_log.h for detail.

Fixes: 5e7596ba7cb3 ("vdpa/sfc: introduce Xilinx vDPA driver")

Signed-off-by: Weiguo Li <liwg06 at foxmail.com>
---
 drivers/vdpa/sfc/sfc_vdpa.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/sfc/sfc_vdpa.c b/drivers/vdpa/sfc/sfc_vdpa.c
index fccdd8c687..53f598facc 100644
--- a/drivers/vdpa/sfc/sfc_vdpa.c
+++ b/drivers/vdpa/sfc/sfc_vdpa.c
@@ -328,7 +328,8 @@ sfc_vdpa_pci_remove(struct rte_pci_device *pci_dev)
 
 	sva = sfc_vdpa_get_adapter_by_dev(pci_dev);
 	if (sva == NULL) {
-		sfc_vdpa_info(sva, "invalid device: %s", pci_dev->name);
+		SFC_VDPA_GENERIC_LOG(INFO,
+			"Invalid device: %s.", pci_dev->name);
 		return -1;
 	}
 
-- 
2.25.1



More information about the dev mailing list