From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 760FC41E25; Thu, 9 Mar 2023 13:38:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 49C0042D0B; Thu, 9 Mar 2023 13:38:11 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 987CA42C54 for ; Thu, 9 Mar 2023 13:38:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678365489; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2QEfrNwvbphHtpQwEtIePdxHPz/fRpK8TJGKQErh2NI=; b=T0oEEcuqr5XJvupIOK79YFBKjg+3aHqfhvmP+0OF+ipynNZqDpwdLOl8GRh0W92lY6oQgd 3/dzuHDRcNaqABvtj+ohCiXSHiG50RQvwCzeU3lxL/3WcPJzrtkhnWtrcWCKI1Od+0QCb8 9e6sGSnEk+1kZbL9uhbtobxLrSyJkzw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-557-qr6tV7Q_OPqzAyiYHwO50w-1; Thu, 09 Mar 2023 07:38:03 -0500 X-MC-Unique: qr6tV7Q_OPqzAyiYHwO50w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 560301991C46; Thu, 9 Mar 2023 12:38:03 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A5E2C15BA0; Thu, 9 Mar 2023 12:38:02 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stable@dpdk.org, Maxime Coquelin , Chenbo Xia , Hyong Youb Kim , Harman Kalra Subject: [PATCH 2/3] net/vhost: fix leak in interrupt handle setup Date: Thu, 9 Mar 2023 13:37:51 +0100 Message-Id: <20230309123752.2237828-3-david.marchand@redhat.com> In-Reply-To: <20230309123752.2237828-1-david.marchand@redhat.com> References: <20230309123752.2237828-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Do a systematic cleanup if any part of the interrupt handle setup fails. Fixes: d61138d4f0e2 ("drivers: remove direct access to interrupt handle") Cc: stable@dpdk.org Signed-off-by: David Marchand --- drivers/net/vhost/rte_eth_vhost.c | 53 ++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 198bf4d1f4..96deb18d91 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -686,25 +686,32 @@ eth_vhost_install_intr(struct rte_eth_dev *dev) dev->intr_handle = rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE); if (dev->intr_handle == NULL) { VHOST_LOG(ERR, "Fail to allocate intr_handle\n"); - return -ENOMEM; + ret = -ENOMEM; + goto error; + } + if (rte_intr_efd_counter_size_set(dev->intr_handle, sizeof(uint64_t))) { + ret = -rte_errno; + goto error; } - if (rte_intr_efd_counter_size_set(dev->intr_handle, sizeof(uint64_t))) - return -rte_errno; if (rte_intr_vec_list_alloc(dev->intr_handle, NULL, nb_rxq)) { - VHOST_LOG(ERR, - "Failed to allocate memory for interrupt vector\n"); - rte_intr_instance_free(dev->intr_handle); - return -ENOMEM; + VHOST_LOG(ERR, "Failed to allocate memory for interrupt vector\n"); + ret = -ENOMEM; + goto error; } VHOST_LOG(INFO, "Prepare intr vec\n"); for (i = 0; i < nb_rxq; i++) { - if (rte_intr_vec_list_index_set(dev->intr_handle, i, RTE_INTR_VEC_RXTX_OFFSET + i)) - return -rte_errno; - if (rte_intr_efds_index_set(dev->intr_handle, i, -1)) - return -rte_errno; + if (rte_intr_vec_list_index_set(dev->intr_handle, i, + RTE_INTR_VEC_RXTX_OFFSET + i)) { + ret = -rte_errno; + goto error; + } + if (rte_intr_efds_index_set(dev->intr_handle, i, -1)) { + ret = -rte_errno; + goto error; + } vq = dev->data->rx_queues[i]; if (!vq) { VHOST_LOG(INFO, "rxq-%d not setup yet, skip!\n", i); @@ -729,16 +736,24 @@ eth_vhost_install_intr(struct rte_eth_dev *dev) VHOST_LOG(INFO, "Installed intr vec for rxq-%d\n", i); } - if (rte_intr_nb_efd_set(dev->intr_handle, nb_rxq)) - return -rte_errno; - - if (rte_intr_max_intr_set(dev->intr_handle, nb_rxq + 1)) - return -rte_errno; - - if (rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_VDEV)) - return -rte_errno; + if (rte_intr_nb_efd_set(dev->intr_handle, nb_rxq)) { + ret = -rte_errno; + goto error; + } + if (rte_intr_max_intr_set(dev->intr_handle, nb_rxq + 1)) { + ret = -rte_errno; + goto error; + } + if (rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_VDEV)) { + ret = -rte_errno; + goto error; + } return 0; + +error: + eth_vhost_uninstall_intr(dev); + return ret; } static void -- 2.39.2