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 0427BA0527 for ; Mon, 9 Nov 2020 13:11:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EF2642B9D; Mon, 9 Nov 2020 13:11:27 +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 CDB812B9D for ; Mon, 9 Nov 2020 13:11:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604923884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QYUXXTFT98yQYh9fubBnU6IQpg7jpat9UTjFQ1ioT+o=; b=FVEsmwiex8qu5rsPrS7vYOaQ69ki8r3etsmePFZS1ZZQwM5EmiMrim9ghzMRrdTbkxOHlt lVeSKfRzw7CyKDz9qjMp2T332M4gxjEFKJNt0D1sC9oZheH8J4OSrxh0I+CykSIBfzH7rC s8OygPtxSM4WubxCMv/7COPjhxkA0XA= 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-109-t50peqQZPA-PM9Q6YncChA-1; Mon, 09 Nov 2020 07:11:22 -0500 X-MC-Unique: t50peqQZPA-PM9Q6YncChA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 00C751009E20; Mon, 9 Nov 2020 12:11:21 +0000 (UTC) Received: from [10.36.110.32] (unknown [10.36.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7FB2A5C22B; Mon, 9 Nov 2020 12:11:19 +0000 (UTC) To: "Xia, Chenbo" , "dev@dpdk.org" , "Ding, Xuan" , "stephen@networkplumber.org" , "thomas@monjalon.net" , "stable@dpdk.org" References: <20201109112600.250779-1-maxime.coquelin@redhat.com> <20201109112600.250779-3-maxime.coquelin@redhat.com> From: Maxime Coquelin Message-ID: <89fd56e0-e36a-9adb-75ce-86a3b7e72687@redhat.com> Date: Mon, 9 Nov 2020 13:11:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-stable] [PATCH v2 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" On 11/9/20 1:07 PM, Xia, Chenbo wrote: > Hi Maxime, > >> -----Original Message----- >> From: Maxime Coquelin >> Sent: Monday, November 9, 2020 7:26 PM >> To: dev@dpdk.org; Ding, Xuan ; >> stephen@networkplumber.org; thomas@monjalon.net; stable@dpdk.org; Xia, >> Chenbo >> Cc: Maxime Coquelin >> Subject: [PATCH v2 2/3] vhost: fix fd leak in dirty logging setup >> >> 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 | 8 ++++++-- >> 1 file changed, 6 insertions(+), 2 deletions(-) >> >> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c >> index 473fd778ca..e4ad5f6baf 100644 >> --- a/lib/librte_vhost/vhost_user.c >> +++ b/lib/librte_vhost/vhost_user.c >> @@ -2076,7 +2076,7 @@ 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; > > I remember we have agreed on simply return here? As I look back to v1, I think > you may modify the wrong place. Because I see another 'goto close_msg_fds' is > deleted compared with v1 😊. > > 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; ... I need more coffee it seems! Of course you are right, I reverted the wrong line. Thanks for catching it. v3 on its way. Thanks, Maxime > Thanks! > Chenbo > >> } >> >> if (msg->size != sizeof(VhostUserLog)) { >> @@ -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 >