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 71187A0527; Mon, 9 Nov 2020 12:27:12 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 571FD6CAC; Mon, 9 Nov 2020 12:26:23 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by dpdk.org (Postfix) with ESMTP id C67E869A4 for ; Mon, 9 Nov 2020 12:26:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604921178; 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=S7+QGytJ5WUadFQe2GrXpq+n2tJCEDfsi3MQxttmnT4=; b=RckW9y3X/+RB1RgN7jHQS6GlTXji7lRqGqisbrDkFrS43F4+QtWtxJiH8I3DZOfqVfIeBh CjQ4AXcPqZIwFSaosk/Kao6oqKqvbLMbtOeMhn23Uieo4s2d2OA+fl3PFPaJ35xMNSeYyL RKsp3ht0wcEIeG1yUYVtJPAaCBSTtpY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-141-8KkIUHiAOKilTOn14YvbMw-1; Mon, 09 Nov 2020 06:26:16 -0500 X-MC-Unique: 8KkIUHiAOKilTOn14YvbMw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A38515F9EA; Mon, 9 Nov 2020 11:26:14 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED6646EF5B; Mon, 9 Nov 2020 11:26:12 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, xuan.ding@intel.com, stephen@networkplumber.org, thomas@monjalon.net, stable@dpdk.org, chenbo.xia@intel.com Cc: Maxime Coquelin Date: Mon, 9 Nov 2020 12:26:00 +0100 Message-Id: <20201109112600.250779-4-maxime.coquelin@redhat.com> In-Reply-To: <20201109112600.250779-1-maxime.coquelin@redhat.com> References: <20201109112600.250779-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH v2 3/3] vhost: fix fd leak in kick setup 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 a file descriptor leak which happens in the error path of vhost_user_set_vring_kick(). Fixes: 4796ad63ba1f ("examples/vhost: import userspace vhost application") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia --- lib/librte_vhost/vhost_user.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index e4ad5f6baf..e8478f2551 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1855,8 +1855,12 @@ vhost_user_set_vring_kick(struct virtio_net **pdev, struct VhostUserMsg *msg, /* Interpret ring addresses only when ring is started. */ dev = translate_ring_addresses(dev, file.index); - if (!dev) + if (!dev) { + if (file.fd != VIRTIO_INVALID_EVENTFD) + close(file.fd); + return RTE_VHOST_MSG_RESULT_ERR; + } *pdev = dev; -- 2.26.2