The 'info' struct was being declared as a NULL pointer. If a NULL
pointer is passed to 'rte_dma_info_get', EINVAL is returned and the
struct is not populated. This subsequently causes a segfault when
dereferencing 'info'.

This patch fixes the issue by simply declaring 'info' on the stack and
passing its address to 'rte_dma_info_get'.

Fixes: 9449330a8458 ("dma/idxd: create dmadev instances on PCI probe")
Cc: sta...@dpdk.org

Signed-off-by: Kevin Laatz <kevin.la...@intel.com>
Acked-by: Bruce Richardson <bruce.richard...@intel.com>
---
 drivers/dma/idxd/idxd_pci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/idxd/idxd_pci.c b/drivers/dma/idxd/idxd_pci.c
index 2c3b01cd2b..2f8ec06d9e 100644
--- a/drivers/dma/idxd/idxd_pci.c
+++ b/drivers/dma/idxd/idxd_pci.c
@@ -380,10 +380,10 @@ idxd_dmadev_remove_pci(struct rte_pci_device *dev)
        IDXD_PMD_INFO("Closing %s on NUMA node %d", name, 
dev->device.numa_node);
 
        RTE_DMA_FOREACH_DEV(i) {
-               struct rte_dma_info *info = {0};
-               rte_dma_info_get(i, info);
-               if (strncmp(name, info->dev_name, strlen(name)) == 0)
-                       idxd_dmadev_destroy(info->dev_name);
+               struct rte_dma_info info;
+               rte_dma_info_get(i, &info);
+               if (strncmp(name, info.dev_name, strlen(name)) == 0)
+                       idxd_dmadev_destroy(info.dev_name);
        }
 
        return 0;
-- 
2.31.1

Reply via email to