eal/linux: fix device hotplug
authorDavid Marchand <david.marchand@redhat.com>
Tue, 2 Nov 2021 07:52:58 +0000 (08:52 +0100)
committerDavid Marchand <david.marchand@redhat.com>
Thu, 4 Nov 2021 14:13:41 +0000 (15:13 +0100)
The device event interrupt handler was always freed.

Bugzilla ID: 845
Fixes: c2bd9367e18f ("lib: remove direct access to interrupt handle")

Signed-off-by: David Marchand <david.marchand@redhat.com>
Tested-by: Yan Xia <yanx.xia@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/eal/linux/eal_dev.c

index 6aaeffb..1fd00a4 100644 (file)
@@ -320,10 +320,12 @@ rte_dev_event_monitor_start(void)
                goto exit;
        }
 
-       if (rte_intr_type_set(intr_handle, RTE_INTR_HANDLE_DEV_EVENT))
+       ret = rte_intr_type_set(intr_handle, RTE_INTR_HANDLE_DEV_EVENT);
+       if (ret)
                goto exit;
 
-       if (rte_intr_fd_set(intr_handle, -1))
+       ret = rte_intr_fd_set(intr_handle, -1);
+       if (ret)
                goto exit;
 
        ret = dev_uev_socket_fd_create();
@@ -342,7 +344,10 @@ rte_dev_event_monitor_start(void)
        monitor_refcount++;
 
 exit:
-       rte_intr_instance_free(intr_handle);
+       if (ret) {
+               rte_intr_instance_free(intr_handle);
+               intr_handle = NULL;
+       }
        rte_rwlock_write_unlock(&monitor_lock);
        return ret;
 }
@@ -373,6 +378,7 @@ rte_dev_event_monitor_stop(void)
 
        close(rte_intr_fd_get(intr_handle));
        rte_intr_instance_free(intr_handle);
+       intr_handle = NULL;
 
        monitor_refcount--;