[v2] examples/vhost: fix floating point exception when no VMDq

Message ID 20220518133633.1634902-1-yuanx.wang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series [v2] examples/vhost: fix floating point exception when no VMDq |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS

Commit Message

Wang, YuanX May 18, 2022, 1:36 p.m. UTC
  If the VMDQ limits is 0, a divide-by-zero error occurs.
This patch replaces throwing a floating point exception with
a normal error message.

Fixes: d19533e86f ("examples/vhost: copy old vhost example")
Cc: stable@dpdk.org

Signed-off-by: Yuan Wang <yuanx.wang@intel.com>
---
 examples/vhost/main.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Chenbo Xia May 30, 2022, 2:52 a.m. UTC | #1
> -----Original Message-----
> From: Wang, YuanX <yuanx.wang@intel.com>
> Sent: Wednesday, May 18, 2022 9:37 PM
> To: maxime.coquelin@redhat.com; Xia, Chenbo <chenbo.xia@intel.com>
> Cc: dev@dpdk.org; Hu, Jiayu <jiayu.hu@intel.com>; He, Xingguang
> <xingguang.he@intel.com>; Wang, YuanX <yuanx.wang@intel.com>;
> stable@dpdk.org
> Subject: [PATCH v2] examples/vhost: fix floating point exception when no
> VMDq
> 
> If the VMDQ limits is 0, a divide-by-zero error occurs.
> This patch replaces throwing a floating point exception with
> a normal error message.
> 
> Fixes: d19533e86f ("examples/vhost: copy old vhost example")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yuan Wang <yuanx.wang@intel.com>
> ---
>  examples/vhost/main.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> index c4d46de1c5..48d9f3802f 100644
> --- a/examples/vhost/main.c
> +++ b/examples/vhost/main.c
> @@ -400,6 +400,10 @@ port_init(uint16_t port)
> 
>  		return retval;
>  	}
> +	if (dev_info.max_vmdq_pools == 0) {
> +		RTE_LOG(ERR, VHOST_PORT, "Failed to get VMDQ info.\n");
> +		return -1;
> +	}
> 
>  	rxconf = &dev_info.default_rxconf;
>  	txconf = &dev_info.default_txconf;
> --
> 2.25.1

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  
Maxime Coquelin June 1, 2022, 10:09 a.m. UTC | #2
On 5/18/22 15:36, Yuan Wang wrote:
> If the VMDQ limits is 0, a divide-by-zero error occurs.
> This patch replaces throwing a floating point exception with
> a normal error message.
> 
> Fixes: d19533e86f ("examples/vhost: copy old vhost example")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yuan Wang <yuanx.wang@intel.com>
> ---
>   examples/vhost/main.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> index c4d46de1c5..48d9f3802f 100644
> --- a/examples/vhost/main.c
> +++ b/examples/vhost/main.c
> @@ -400,6 +400,10 @@ port_init(uint16_t port)
>   
>   		return retval;
>   	}
> +	if (dev_info.max_vmdq_pools == 0) {
> +		RTE_LOG(ERR, VHOST_PORT, "Failed to get VMDQ info.\n");
> +		return -1;
> +	}
>   
>   	rxconf = &dev_info.default_rxconf;
>   	txconf = &dev_info.default_txconf;


Applied to dpdk-next-virtio/main.

Thanks,
Maxime
  

Patch

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index c4d46de1c5..48d9f3802f 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -400,6 +400,10 @@  port_init(uint16_t port)
 
 		return retval;
 	}
+	if (dev_info.max_vmdq_pools == 0) {
+		RTE_LOG(ERR, VHOST_PORT, "Failed to get VMDQ info.\n");
+		return -1;
+	}
 
 	rxconf = &dev_info.default_rxconf;
 	txconf = &dev_info.default_txconf;