From: Yunjian Wang <wangyunjian@huawei.com>
To: <dev@dpdk.org>
Cc: <maxime.coquelin@redhat.com>, <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
Date: Sat, 8 Jan 2022 15:52:31 +0800 [thread overview]
Message-ID: <3fac6dba701731df12ea8cce82a539036b1f5e70.1641626365.git.wangyunjian@huawei.com> (raw)
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
next reply other threads:[~2022-01-08 7:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-08 7:52 Yunjian Wang [this message]
2022-01-17 3:22 ` Xia, Chenbo
2022-01-27 5:26 ` Xia, Chenbo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3fac6dba701731df12ea8cce82a539036b1f5e70.1641626365.git.wangyunjian@huawei.com \
--to=wangyunjian@huawei.com \
--cc=chenbo.xia@intel.com \
--cc=dev@dpdk.org \
--cc=dingxiaoxiong@huawei.com \
--cc=maxime.coquelin@redhat.com \
--cc=stable@dpdk.org \
--cc=xudingke@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).