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 103D6A04B1 for ; Thu, 5 Nov 2020 12:46:21 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 08950C7FA; Thu, 5 Nov 2020 12:46:13 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by dpdk.org (Postfix) with ESMTP id B43D4C30D for ; Thu, 5 Nov 2020 12:46:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604576767; 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=AyZ9KbxwRDASTYStxoPP6fJGqyGHnI6EtIZFcQa87Pk=; b=WMdOUxgO2NW4sb8LgMMperyX96EYI8QuX270QQzT5RJZ5KRDxWsQroSLSyfqxWAkolgjrG MjxsVo8gL3PZtYAUGMLk7TDdb1X0KQ8Rqt7TDcQGys0L+t6iXDYzJOVorSqro4moh9NFcl Q9vTUF5cS7iAIE4ySI48/Eykp3oxEK4= 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-282-4SfaRS9IOMuOlKEmDLVe7A-1; Thu, 05 Nov 2020 06:46:03 -0500 X-MC-Unique: 4SfaRS9IOMuOlKEmDLVe7A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D3EA85F9D2; Thu, 5 Nov 2020 11:46:01 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 013E15D9D5; Thu, 5 Nov 2020 11:45:59 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, xuan.ding@intel.com, stephen@networkplumber.org, ferruh.yigit@intel.com, thomas@monjalon.net, chenbo.xia@intel.com Cc: stable@dpdk.org, Maxime Coquelin Date: Thu, 5 Nov 2020 12:45:48 +0100 Message-Id: <20201105114549.97717-3-maxime.coquelin@redhat.com> In-Reply-To: <20201105114549.97717-1-maxime.coquelin@redhat.com> References: <20201105114549.97717-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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-stable] [PATCH 2/3] vhost: fix fd leak in dirty logging setup 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" This patch fixes a file descriptor leak which happens in the error path of vhost_user_set_log_base(). Fixes: 4796ad63ba1f ("examples/vhost: import userspace vhost application") Cc: stable@dpdk.org Reported-by: Xuan Ding Signed-off-by: Maxime Coquelin --- lib/librte_vhost/vhost_user.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 473fd778ca..7dfda15991 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -2076,14 +2076,14 @@ vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg, if (fd < 0) { VHOST_LOG_CONFIG(ERR, "invalid log fd: %d\n", fd); - return RTE_VHOST_MSG_RESULT_ERR; + goto close_msg_fds; } if (msg->size != sizeof(VhostUserLog)) { VHOST_LOG_CONFIG(ERR, "invalid log base msg size: %"PRId32" != %d\n", msg->size, (int)sizeof(VhostUserLog)); - return RTE_VHOST_MSG_RESULT_ERR; + goto close_msg_fds; } size = msg->payload.log.mmap_size; @@ -2094,7 +2094,7 @@ vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg, VHOST_LOG_CONFIG(ERR, "log offset %#"PRIx64" and log size %#"PRIx64" overflow\n", off, size); - return RTE_VHOST_MSG_RESULT_ERR; + goto close_msg_fds; } VHOST_LOG_CONFIG(INFO, @@ -2131,6 +2131,10 @@ vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg, msg->fd_num = 0; return RTE_VHOST_MSG_RESULT_REPLY; + +close_msg_fds: + close_msg_fds(msg); + return RTE_VHOST_MSG_RESULT_ERR; } static int vhost_user_set_log_fd(struct virtio_net **pdev __rte_unused, -- 2.26.2