net/virtio-user: check tap system call setting

Setting the flags of tapfd may fail and the return value
should be checked.

Coverity issue: 140739
Fixes: e3b434818bbb ("net/virtio-user: support kernel vhost")
Cc: stable@dpdk.org

Signed-off-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
This commit is contained in:
Chenbo Xia 2020-07-29 13:12:30 +00:00 committed by Ferruh Yigit
parent 3d4cd4be57
commit 570ee25677

View File

@ -128,7 +128,10 @@ vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq,
goto error;
}
fcntl(tapfd, F_SETFL, O_NONBLOCK);
if (fcntl(tapfd, F_SETFL, O_NONBLOCK) < 0) {
PMD_DRV_LOG(ERR, "fcntl tapfd failed: %s", strerror(errno));
goto error;
}
if (ioctl(tapfd, TUNSETVNETHDRSZ, &hdr_size) < 0) {
PMD_DRV_LOG(ERR, "TUNSETVNETHDRSZ failed: %s", strerror(errno));