net/ifc: store only registered device instance
authorXiao Wang <xiao.w.wang@intel.com>
Tue, 18 Dec 2018 08:02:02 +0000 (16:02 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 21 Dec 2018 15:22:40 +0000 (16:22 +0100)
If driver fails to register ifc VF device into vhost lib, then this
device should not be stored.

Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
Cc: stable@dpdk.org
Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/net/ifc/ifcvf_vdpa.c

index aacd5f9..6fcd50b 100644 (file)
@@ -781,10 +781,6 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
        internal->dev_addr.type = PCI_ADDR;
        list->internal = internal;
 
-       pthread_mutex_lock(&internal_list_lock);
-       TAILQ_INSERT_TAIL(&internal_list, list, next);
-       pthread_mutex_unlock(&internal_list_lock);
-
        internal->did = rte_vdpa_register_device(&internal->dev_addr,
                                &ifcvf_ops);
        if (internal->did < 0) {
@@ -792,6 +788,10 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
                goto error;
        }
 
+       pthread_mutex_lock(&internal_list_lock);
+       TAILQ_INSERT_TAIL(&internal_list, list, next);
+       pthread_mutex_unlock(&internal_list_lock);
+
        rte_atomic32_set(&internal->started, 1);
        update_datapath(internal);