patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/virtio-user: check fd flags getting failure
@ 2022-01-08  7:52 Yunjian Wang
  2022-01-17  3:22 ` Xia, Chenbo
  0 siblings, 1 reply; 2+ messages in thread
From: Yunjian Wang @ 2022-01-08  7:52 UTC (permalink / raw)
  To: dev
  Cc: maxime.coquelin, chenbo.xia, dingxiaoxiong, xudingke,
	Yunjian Wang, stable

The function fcntl() could return errors,
the return value need to be checked.

Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/virtio/virtio_user/vhost_user.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
index cc830a660f..0a39393c45 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -840,8 +840,10 @@ vhost_user_setup(struct virtio_user_dev *dev)
 	}
 
 	flag = fcntl(fd, F_GETFD);
-	if (fcntl(fd, F_SETFD, flag | FD_CLOEXEC) < 0)
-		PMD_DRV_LOG(WARNING, "fcntl failed, %s", strerror(errno));
+	if (flag == -1)
+		PMD_DRV_LOG(WARNING, "fcntl get fd failed, %s", strerror(errno));
+	else if (fcntl(fd, F_SETFD, flag | FD_CLOEXEC) < 0)
+		PMD_DRV_LOG(WARNING, "fcntl set fd failed, %s", strerror(errno));
 
 	memset(&un, 0, sizeof(un));
 	un.sun_family = AF_UNIX;
-- 
2.27.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [dpdk-dev] [PATCH] net/virtio-user: check fd flags getting failure
  2022-01-08  7:52 [dpdk-dev] [PATCH] net/virtio-user: check fd flags getting failure Yunjian Wang
@ 2022-01-17  3:22 ` Xia, Chenbo
  0 siblings, 0 replies; 2+ messages in thread
From: Xia, Chenbo @ 2022-01-17  3:22 UTC (permalink / raw)
  To: Yunjian Wang, dev; +Cc: maxime.coquelin, dingxiaoxiong, xudingke, stable

> -----Original Message-----
> From: Yunjian Wang <wangyunjian@huawei.com>
> Sent: Saturday, January 8, 2022 3:53 PM
> To: dev@dpdk.org
> Cc: maxime.coquelin@redhat.com; Xia, Chenbo <chenbo.xia@intel.com>;
> dingxiaoxiong@huawei.com; xudingke@huawei.com; Yunjian Wang
> <wangyunjian@huawei.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] net/virtio-user: check fd flags getting failure
> 
> The function fcntl() could return errors,
> the return value need to be checked.
> 
> Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>  drivers/net/virtio/virtio_user/vhost_user.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_user/vhost_user.c
> b/drivers/net/virtio/virtio_user/vhost_user.c
> index cc830a660f..0a39393c45 100644
> --- a/drivers/net/virtio/virtio_user/vhost_user.c
> +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> @@ -840,8 +840,10 @@ vhost_user_setup(struct virtio_user_dev *dev)
>  	}
> 
>  	flag = fcntl(fd, F_GETFD);
> -	if (fcntl(fd, F_SETFD, flag | FD_CLOEXEC) < 0)
> -		PMD_DRV_LOG(WARNING, "fcntl failed, %s", strerror(errno));
> +	if (flag == -1)
> +		PMD_DRV_LOG(WARNING, "fcntl get fd failed, %s", strerror(errno));
> +	else if (fcntl(fd, F_SETFD, flag | FD_CLOEXEC) < 0)
> +		PMD_DRV_LOG(WARNING, "fcntl set fd failed, %s", strerror(errno));
> 
>  	memset(&un, 0, sizeof(un));
>  	un.sun_family = AF_UNIX;
> --
> 2.27.0

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-17  3:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-08  7:52 [dpdk-dev] [PATCH] net/virtio-user: check fd flags getting failure Yunjian Wang
2022-01-17  3:22 ` Xia, Chenbo

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git