Skip to contentSkip to conversation

net/virtio-user: fix return value check

PATCH Applied Chenbo Xia 2 participants 3 messages Jul 29, 2020 Network drivers

lore
Share & tools
lore

Chenbo Xia

author
#0 lore raw

PATCH 1/1 net/virtio-user: fix return value check

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")
---
 drivers/net/virtio/virtio_user/vhost_kernel_tap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_user/vhost_kernel_tap.c +4 -1
index 2fa4f0d66..acddefa33 100644
@@ -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));
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Chenbo Xia

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")
---
 drivers/net/virtio/virtio_user/vhost_kernel_tap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_user/vhost_kernel_tap.c +0 -0
index 2fa4f0d66..acddefa33 100644
@@ -128,7 +128,10 @@ vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq,
 		goto error;

drivers/net/virtio/virtio_user/vhost_kernel_tap.c vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq, · line 137

Quoted 10 lines
drivers/net/virtio/virtio_user/vhost_kernel_tap.c +4 -1
 	}
 
-	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));

Thanks,
Maxime

#2 lore raw
In reply to Chenbo Xia
Quoted 11 lines · Chenbo Xia

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")
---
 drivers/net/virtio/virtio_user/vhost_kernel_tap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Applied to dpdk-next-virtio/master.

Thanks,
Maxime