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 6DF4C3256 for ; Thu, 6 Sep 2018 15:18:25 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id u11-v6so4980034plq.5 for ; Thu, 06 Sep 2018 06:18:25 -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=NkCHBrx4A7O4y2Q5n2kpYrau419HECee5IgyR21vFtK2vlFiDEsrW+ieO31NZQCAyv Z+bp4zdvVlv+8bF6Aibvs7iFFjlg6XqdqPzgnyQgtXg+xo/JID6FdRE/uZ2iq/3mtZ1R OpQcTWFEmreIW/yDi6rB1UgbrQMgHk88bG9hU8HOVDdall0wXlBKweZedxN4KRJKgeDY PYDWu4L7PzKvgEXA7y4BZyzSvomuN4nREMX66U4Mb4SCcy9G9nvJzQA2/RW2TFzBUXFd +ZsZOcbd4DfTuXfsysnJWobMGG/cn5+vsbKIs2Wwa/rM6CfLckUzdKDXIUOfKfaIgp7C PhOg== 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=UT4eGplyOsdJ54UCOGpnsjkgoXpvnELIvJxNl39Z7V3kK7YQ8jseNuqF7QN8soN0Z2 0duMadJ84qKDAG4WYjQ2Re/+hk5FknvPs6veT8BKbXcK9eSvTlajpM4+bvM+rW+s1tYj kEUKfn+0N2+LekTt6f5jMKzsS1FKKZU5a+9j3UWHJQLggOEDq10y9GIWL8Sr5fhK+bEj 3qvqUiAb/K1xLStoUgNY7NYl1LqA1PI/HAjoUXbRMIB7ZPxAu/SOkDGCA+aP3vtP90sO 7nYngTkTGTFBtcs9+nyBOPZH9e5VBUdr8hr7MzQWBoJc7gCNpkbrIkCUH6sKoISPngAf bvow== X-Gm-Message-State: APzg51DspjfVVT6SRYq1CGMtj2vqke4rtpow6MgR/ugdTBRkc7cuajY1 f+kPM0NfpkNGjBvcsjF5wDw= X-Google-Smtp-Source: ANB0VdYf6K5QLYSk9crxE0zVwV6YoXfbsd15dv2ECCrlY01NNblRNICttPU04Xob2I3oohu6/3VSNg== X-Received: by 2002:a17:902:8506:: with SMTP id bj6-v6mr2551854plb.210.1536239904787; Thu, 06 Sep 2018 06:18:24 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id w13-v6sm5701421pgs.89.2018.09.06.06.18.23 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 06 Sep 2018 06:18:24 -0700 (PDT) From: Qiang Zhou To: 525930045@qq.com Cc: Qiang Zhou , stable@dpdk.org Date: Thu, 6 Sep 2018 21:18:05 +0800 Message-Id: <20180906131805.95151-1-zhouqiang2633@gmail.com> X-Mailer: git-send-email 2.14.3 (Apple Git-98) Subject: [dpdk-stable] [PATCH] vhost: fix crash on unregistering in client mode X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2018 13:18:25 -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)