net/virtio-user: fix return value check
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")
Signed-off-by Chenbo Xia <[email protected]>
--- 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
@@ -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
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")Signed-off-by Chenbo Xia <[email protected]>--- 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@@ -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));
Reviewed-by Maxime Coquelin <[email protected]>
Thanks,
Maxime
Maxime Coquelin
AppliedQuoted 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")Signed-off-by Chenbo Xia <[email protected]>--- 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