From patchwork Mon Sep 24 13:43:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Lucero X-Patchwork-Id: 45202 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3F0DC2B8C; Mon, 24 Sep 2018 15:44:38 +0200 (CEST) Received: from netronome.com (host-79-78-33-110.static.as9105.net [79.78.33.110]) by dpdk.org (Postfix) with ESMTP id 2905A1AFF; Mon, 24 Sep 2018 15:44:36 +0200 (CEST) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w8ODhOE8029416; Mon, 24 Sep 2018 14:43:24 +0100 Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id w8ODhOep029415; Mon, 24 Sep 2018 14:43:24 +0100 From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org Date: Mon, 24 Sep 2018 14:43:24 +0100 Message-Id: <1537796604-29378-1-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] ethdev: fix error handling logic 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch fixes how function exit is handled when errors inside rte_eth_dev_create. Fixes: e489007a411c ("ethdev: add generic create/destroy ethdev APIs") Cc: stable@dpdk.org Signed-off-by: Alejandro Lucero Reviewed-by: Andrew Rybchenko --- lib/librte_ethdev/rte_ethdev.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index aa7730c..ef99f70 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3467,10 +3467,8 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx, if (rte_eal_process_type() == RTE_PROC_PRIMARY) { ethdev = rte_eth_dev_allocate(name); - if (!ethdev) { - retval = -ENODEV; - goto probe_failed; - } + if (!ethdev) + return -ENODEV; if (priv_data_size) { ethdev->data->dev_private = rte_zmalloc_socket( @@ -3480,7 +3478,7 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx, if (!ethdev->data->dev_private) { RTE_LOG(ERR, EAL, "failed to allocate private data"); retval = -ENOMEM; - goto probe_failed; + goto data_alloc_failed; } } } else { @@ -3488,8 +3486,7 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx, if (!ethdev) { RTE_LOG(ERR, EAL, "secondary process attach failed, " "ethdev doesn't exist"); - retval = -ENODEV; - goto probe_failed; + return -ENODEV; } } @@ -3518,6 +3515,7 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx, if (rte_eal_process_type() == RTE_PROC_PRIMARY) rte_free(ethdev->data->dev_private); +data_alloc_failed: rte_eth_dev_release_port(ethdev); return retval;