From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id 8A3F03256; Thu, 6 Sep 2018 15:20:02 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id f6-v6so4994522plo.1; Thu, 06 Sep 2018 06:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=CbUsQGGX4ebVZA+fd+lAVVXMrqK7d+k8zAcVFJCguuE=; b=L3wPo/g4JRNpVPwApdKooeylfF+KvOeUg0vWhUV5XaRe97fVmHymsKm6iUSX1ssD1t NpVVNww536HlnL7XV5+d0NLTcSNHI95Q6SHafuRv03iMMin1m9B2cn7a/FKJcRC072g8 XTj+GHaynvDPbAX4ndC0O+xJ4h/1XYvSnhNa+eJPVzwh6NSTQ8UCKPMel310TiTGiaNn q36VKF6WR75uarXqWErsjX3MHqlmALGJ4Y+WKSAhlvxZzsAENC8RIYdmULyYlr6NcrxE IKZzDpiJCBUkj5UfKsdIUKeVIe+vHuNUSOovDumtWVQW/RU1bCqHUSbK+4y90Pe70zuS rzbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=CbUsQGGX4ebVZA+fd+lAVVXMrqK7d+k8zAcVFJCguuE=; b=EWLjVf+gXNjG9bnca8cXuzoEZQrDBAaqtjOF93cz6wLrsG9apUEwMhGrxb2M1H7nTx AjPtbKYVJmNZBaQ8psB3u0PnCT9bSHELajsp1enmpO9Jdz6jYk6F5BOIdJezZA2ZR8ML 3uKB0m3y/U1uLuXN5/8GhLwp/ayx+U81sqiw9hB2fwTyAgeegxjcgdIMe1+fRJYgG/Kb YpLtaKz7rINMBpwjM+shfHUqf4SjPRZpvJZF9/mI+c1OA+WFntirL5OpdJZAeUSTmlT3 KAFkDDT2H+Vd9tilpjVyI0HduIimOTc9xYafpi48V8adRGWJoIgzE4mKrDMg7hnwepXc 8vHw== X-Gm-Message-State: APzg51DZ+K//Mpwm55EQjis1MBoV4EFViRNhR3mIaBUltxveGjhA16br 8RGb3+lMGPkeKwp9xkcf/OofY6A/ X-Google-Smtp-Source: ANB0VdY7/F7k53o9JZF7nIPEvq55od7eETIg7YVOWcKkAJm3cbw2tZbEOaWOHKXYMKxseWRBs2rUeg== X-Received: by 2002:a17:902:4001:: with SMTP id b1-v6mr2592998pld.312.1536240001812; Thu, 06 Sep 2018 06:20:01 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id n9-v6sm12549215pfg.21.2018.09.06.06.19.59 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 06 Sep 2018 06:20:01 -0700 (PDT) From: Qiang Zhou To: dev@dpdk.org Cc: Qiang Zhou , stable@dpdk.org Date: Thu, 6 Sep 2018 21:19:41 +0800 Message-Id: <20180906131941.95267-1-zhouqiang2633@gmail.com> X-Mailer: git-send-email 2.14.3 (Apple Git-98) Subject: [dpdk-dev] [PATCH] vhost: fix crash on unregistering in client mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2018 13:20:03 -0000 when rte_vhost_driver_unregister delete the connection fd, the fd lock will prevent the vsocket to be freed. But when vhost_user_msg_handler return error, it will delete vsocket conn_list. And then the fd lock will become invalid. So the vsocket will be freed in rte_vhost_drivere_unregister and the vhost_user_read_cb will reconnect. To fix this: move delete vsocket conn after reconnect Cc: stable@dpdk.org Signed-off-by: Qiang Zhou --- lib/librte_vhost/socket.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index d63031747..43da1c51b 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -293,16 +293,16 @@ vhost_user_read_cb(int connfd, void *dat, int *remove) if (vsocket->notify_ops->destroy_connection) vsocket->notify_ops->destroy_connection(conn->vid); + if (vsocket->reconnect) { + create_unix_socket(vsocket); + vhost_user_start_client(vsocket); + } + pthread_mutex_lock(&vsocket->conn_mutex); TAILQ_REMOVE(&vsocket->conn_list, conn, next); pthread_mutex_unlock(&vsocket->conn_mutex); free(conn); - - if (vsocket->reconnect) { - create_unix_socket(vsocket); - vhost_user_start_client(vsocket); - } } } -- 2.14.3 (Apple Git-98)