From d4653a31e017d80caf4f4111c4c62b815a126eb2 Mon Sep 17 00:00:00 2001 From: Vitaliy Mysak Date: Wed, 4 Mar 2020 10:56:42 +0100 Subject: [PATCH] env_dpdk: dont treat NULL as error in spdk_map_bar_rte() We use `spdk_map_bar_rte()` to read mapped addresses from PCI BARs. This function is currently checking for NULL in each pair. But in PCI memory, some registers can be left unused, in which case they are set to 0. As a result, we may read some NULL pointers from BARs, which is OK. To check if given address is indeed invalid, we should first check if it is used. So it is best to delegate such checks to the user of this function. In fact, users already do the NULL check where it is needed (ex: virtio_pci.c:390, nvme_pcie.c:589) so this patch just removes them from `spdk_map_bar_rte()`. This solves github issue #1206 Change-Id: I88021ceca1b9e9d503b224f790819999cd16da01 Signed-off-by: Vitaliy Mysak Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1129 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto --- lib/env_dpdk/pci.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index 3ce8c7cb93..5cfa636192 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -62,15 +62,7 @@ spdk_map_bar_rte(struct spdk_pci_device *device, uint32_t bar, struct rte_pci_device *dev = device->dev_handle; *mapped_addr = dev->mem_resource[bar].addr; - if (*mapped_addr == NULL) { - return -1; - } - *phys_addr = (uint64_t)dev->mem_resource[bar].phys_addr; - if (*phys_addr == 0) { - return -1; - } - *size = (uint64_t)dev->mem_resource[bar].len; return 0;