net/ixgbe: replace license text with SPDX tag
[dpdk.git] / lib / librte_vhost / socket.c
index f0fdb83..274988c 100644 (file)
@@ -297,13 +297,19 @@ vhost_user_read_cb(int connfd, void *dat, int *remove)
 
        ret = vhost_user_msg_handler(conn->vid, connfd);
        if (ret < 0) {
+               struct virtio_net *dev = get_device(conn->vid);
+
                close(connfd);
                *remove = 1;
-               vhost_destroy_device(conn->vid);
+
+               if (dev)
+                       vhost_destroy_device_notify(dev);
 
                if (vsocket->notify_ops->destroy_connection)
                        vsocket->notify_ops->destroy_connection(conn->vid);
 
+               vhost_destroy_device(conn->vid);
+
                pthread_mutex_lock(&vsocket->conn_mutex);
                TAILQ_REMOVE(&vsocket->conn_list, conn, next);
                pthread_mutex_unlock(&vsocket->conn_mutex);
@@ -549,6 +555,9 @@ find_vhost_user_socket(const char *path)
 {
        int i;
 
+       if (path == NULL)
+               return NULL;
+
        for (i = 0; i < vhost_user.vsocket_cnt; i++) {
                struct vhost_user_socket *vsocket = vhost_user.vsockets[i];
 
@@ -564,7 +573,7 @@ rte_vhost_driver_attach_vdpa_device(const char *path, int did)
 {
        struct vhost_user_socket *vsocket;
 
-       if (rte_vdpa_get_device(did) == NULL)
+       if (rte_vdpa_get_device(did) == NULL || path == NULL)
                return -1;
 
        pthread_mutex_lock(&vhost_user.mutex);
@@ -977,6 +986,9 @@ rte_vhost_driver_unregister(const char *path)
        int count;
        struct vhost_user_connection *conn, *next;
 
+       if (path == NULL)
+               return -1;
+
 again:
        pthread_mutex_lock(&vhost_user.mutex);