[v1] net/virtio-user: fix return value check

Message ID 20200729131230.14847-1-chenbo.xia@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series [v1] net/virtio-user: fix return value check |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Chenbo Xia July 29, 2020, 1:12 p.m. UTC
  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>
---
 drivers/net/virtio/virtio_user/vhost_kernel_tap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Maxime Coquelin July 29, 2020, 2:22 p.m. UTC | #1
On 7/29/20 3:12 PM, Chenbo Xia wrote:
> 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>
> ---
>  drivers/net/virtio/virtio_user/vhost_kernel_tap.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
> index 2fa4f0d66..acddefa33 100644
> --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
> +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
> @@ -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));
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  
Maxime Coquelin July 29, 2020, 2:54 p.m. UTC | #2
On 7/29/20 3:12 PM, Chenbo Xia wrote:
> 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>
> ---
>  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
  

Patch

diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
index 2fa4f0d66..acddefa33 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
@@ -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));