[v2] examples/vhost: fix potentially overflowing expression

Message ID 20210202072421.15890-1-Cheng1.jiang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series [v2] examples/vhost: fix potentially overflowing expression |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing warning Testing issues
ci/intel-Testing fail Testing issues

Commit Message

Jiang, Cheng1 Feb. 2, 2021, 7:24 a.m. UTC
  Change the type of buff_idx from uint64_t to uint32_t to fix coverity
issue.

Coverity issue: 366264
Fixes: a68ba8e0a6b6 ("examples/vhost: refactor vhost data path")

Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
---
v2: fixed the format of git log

 examples/vhost/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.29.2
  

Comments

Maxime Coquelin Feb. 3, 2021, 9:54 a.m. UTC | #1
On 2/2/21 8:24 AM, Cheng Jiang wrote:
> Change the type of buff_idx from uint64_t to uint32_t to fix coverity
> issue.
> 
> Coverity issue: 366264
> Fixes: a68ba8e0a6b6 ("examples/vhost: refactor vhost data path")
> 
> Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
> ---
> v2: fixed the format of git log
> 
>  examples/vhost/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> index 233a2dc6e..e74fc8750 100644
> --- a/examples/vhost/main.c
> +++ b/examples/vhost/main.c
> @@ -864,7 +864,7 @@ static __rte_always_inline void
>  drain_vhost(struct vhost_dev *vdev)
>  {
>  	uint16_t ret;
> -	uint64_t buff_idx = rte_lcore_id() * MAX_VHOST_DEVICE + vdev->vid;
> +	uint32_t buff_idx = rte_lcore_id() * MAX_VHOST_DEVICE + vdev->vid;
>  	uint16_t nr_xmit = vhost_txbuff[buff_idx]->len;
>  	struct rte_mbuf **m = vhost_txbuff[buff_idx]->m_table;
> 
> --
> 2.29.2
> 

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

Thanks,
Maxime
  
Maxime Coquelin Feb. 3, 2021, 5:20 p.m. UTC | #2
On 2/2/21 8:24 AM, Cheng Jiang wrote:
> |Change the type of buff_idx from uint64_t to uint32_t to fix coverity
> issue. Coverity issue: 366264 Fixes: a68ba8e0a6b6 ("examples/vhost:
> refactor vhost data path") Signed-off-by: Cheng Jiang
> <Cheng1.jiang@intel.com> --- v2: fixed the format of git log
> examples/vhost/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)|


Applied to dpdk-next-virtio/main with typo fixed.

Thanks,
Maxime
  

Patch

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 233a2dc6e..e74fc8750 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -864,7 +864,7 @@  static __rte_always_inline void
 drain_vhost(struct vhost_dev *vdev)
 {
 	uint16_t ret;
-	uint64_t buff_idx = rte_lcore_id() * MAX_VHOST_DEVICE + vdev->vid;
+	uint32_t buff_idx = rte_lcore_id() * MAX_VHOST_DEVICE + vdev->vid;
 	uint16_t nr_xmit = vhost_txbuff[buff_idx]->len;
 	struct rte_mbuf **m = vhost_txbuff[buff_idx]->m_table;