From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 81DEDA055A for ; Thu, 27 Feb 2020 10:34:36 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 74E871BFCD; Thu, 27 Feb 2020 10:34:36 +0100 (CET) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id A0C431BFE2 for ; Thu, 27 Feb 2020 10:34:34 +0100 (CET) Received: by mail-wr1-f67.google.com with SMTP id l5so2425148wrx.4 for ; Thu, 27 Feb 2020 01:34:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H9SY9Rdla860ATwcquWEn7YruKj3knFAsBFIcbN6LRs=; b=jMseTPAll+XPtj1uyqeiYN2om+r3JRNplGRBm9MijsGaIHi+xHP0UOLETR4Is8pxWA tO122+XLSP4zFfkGsDhHZyzsgPYYX66Jozsklyfr1omSZDYM+IcTS/oFBhS4QxG8pOt4 Bl0abzkqRlTO34KL3K4XNkh0yGF5sQylAkhgKP6bysF7bqgMMU+qVhelSxn5erE77x7b 4Ts32hrGig1CkUecIq8C/ms7JCHqAxUX3ZthZPdoyaqxImxGy9tumjdOhD225vjLIJWc 5EggcZ3fNf/m/XKWFjeZ7wWwN2/W2K0hkU/R7WvttxqM4gKBjl8g3KtMBAwGs5jMSnlI N3Sg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=H9SY9Rdla860ATwcquWEn7YruKj3knFAsBFIcbN6LRs=; b=Oz+HGwEi/zkeUmoohktniZamktW8mM4aj7IjZWtNZAexbGOvPDRpYdEEGMzHWhLekk h3nwg1hN+TMrSZHUK7EO7fXUrAKRTPt0Lcs/Wc4ncO7bUn4TdyJfFpIgiyL0SrQEluV9 Ib+wFgT82XRi9lEhBqLvH95cXeW8826nrJMzdjLbV7UzL/q+u2UF+MCG7qRlTLAeOe9L lDj4pUwo8ol46c0Fh3v+IX//Whf0/p8IqTTOqPVRfzlkCmx9y7fBdpxbFo9zzkKuwqnI 0+oMbyAFZ9uHQuHpo0Uu9yQZZS+Ic0K3fZDztLQcKtt1b6JOwFT6oAJcrUE/6pl7McOy tthA== X-Gm-Message-State: APjAAAXfPTcDh+kAQttilKSmK+x/vZMrOJB4PRU5/RcuJJRWx6kaR7VX bQgKnYIhSDczwN1i8eSfHTtnBPHo X-Google-Smtp-Source: APXvYqwNA31tW2clhMMnVhjzvCOXfSDScEux+ujQHam7SosL93CPd/s3pl3Iy6JfQyfML7WHzFSicA== X-Received: by 2002:adf:f60b:: with SMTP id t11mr3792791wrp.344.1582796074349; Thu, 27 Feb 2020 01:34:34 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id x21sm6356111wmi.30.2020.02.27.01.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 01:34:33 -0800 (PST) From: luca.boccassi@gmail.com To: Maxime Coquelin Cc: David Marchand , Tiwei Bie , dpdk stable Date: Thu, 27 Feb 2020 09:33:32 +0000 Message-Id: <20200227093402.17690-12-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200227093402.17690-1-luca.boccassi@gmail.com> References: <20200217174546.25334-54-luca.boccassi@gmail.com> <20200227093402.17690-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/vhost: fix setup error path' has been queued to stable release 19.11.1 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: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/29/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From a222f3ee7145254de7847e9c4c7d4cb3e2ea42ce Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Tue, 18 Feb 2020 18:22:39 +0100 Subject: [PATCH] net/vhost: fix setup error path [ upstream commit 3e00307549ef7c90a9752f58f1d423542399267c ] If for some reason vhost_driver_setup() fails, the list element for the device may be freed without being removed from the internal list of devices. This patch fixes all the error paths, by unregistering the device from Vhost library it has been registered, remove the device from the list, reset device vring_state pointer from the global table and only free vring state if it had been allocated. Fixes: 3d01b759d267 ("net/vhost: delay driver setup") Signed-off-by: Maxime Coquelin Reviewed-by: David Marchand Reviewed-by: Tiwei Bie --- drivers/net/vhost/rte_eth_vhost.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 307de2c682..c1b3dffeec 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -879,12 +879,12 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev) list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node); if (list == NULL) - goto error; + return -1; vring_state = rte_zmalloc_socket(name, sizeof(*vring_state), 0, numa_node); if (vring_state == NULL) - goto error; + goto free_list; list->eth_dev = eth_dev; pthread_mutex_lock(&internal_list_lock); @@ -895,30 +895,37 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev) vring_states[eth_dev->data->port_id] = vring_state; if (rte_vhost_driver_register(internal->iface_name, internal->flags)) - goto error; + goto list_remove; if (internal->disable_flags) { if (rte_vhost_driver_disable_features(internal->iface_name, internal->disable_flags)) - goto error; + goto drv_unreg; } if (rte_vhost_driver_callback_register(internal->iface_name, &vhost_ops) < 0) { VHOST_LOG(ERR, "Can't register callbacks\n"); - goto error; + goto drv_unreg; } if (rte_vhost_driver_start(internal->iface_name) < 0) { VHOST_LOG(ERR, "Failed to start driver for %s\n", internal->iface_name); - goto error; + goto drv_unreg; } return 0; -error: +drv_unreg: + rte_vhost_driver_unregister(internal->iface_name); +list_remove: + vring_states[eth_dev->data->port_id] = NULL; + pthread_mutex_lock(&internal_list_lock); + TAILQ_REMOVE(&internal_list, list, next); + pthread_mutex_unlock(&internal_list_lock); rte_free(vring_state); +free_list: rte_free(list); return -1; -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-02-27 09:31:56.244283332 +0000 +++ 0012-net-vhost-fix-setup-error-path.patch 2020-02-27 09:31:55.699945610 +0000 @@ -1,8 +1,10 @@ -From 3e00307549ef7c90a9752f58f1d423542399267c Mon Sep 17 00:00:00 2001 +From a222f3ee7145254de7847e9c4c7d4cb3e2ea42ce Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Tue, 18 Feb 2020 18:22:39 +0100 Subject: [PATCH] net/vhost: fix setup error path +[ upstream commit 3e00307549ef7c90a9752f58f1d423542399267c ] + If for some reason vhost_driver_setup() fails, the list element for the device may be freed without being removed from the internal list of devices. @@ -14,7 +16,6 @@ been allocated. Fixes: 3d01b759d267 ("net/vhost: delay driver setup") -Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin Reviewed-by: David Marchand @@ -24,10 +25,10 @@ 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c -index 90263ae77c..4a7b1b608c 100644 +index 307de2c682..c1b3dffeec 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c -@@ -878,12 +878,12 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev) +@@ -879,12 +879,12 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev) list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node); if (list == NULL) @@ -42,7 +43,7 @@ list->eth_dev = eth_dev; pthread_mutex_lock(&internal_list_lock); -@@ -894,30 +894,37 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev) +@@ -895,30 +895,37 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev) vring_states[eth_dev->data->port_id] = vring_state; if (rte_vhost_driver_register(internal->iface_name, internal->flags))