diff mbox series

vhost: fix unintended sign extension in async split ring

Message ID 20210512023041.30507-1-cheng1.jiang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers show
Series vhost: fix unintended sign extension in async split ring | expand

Checks

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

Commit Message

Jiang, Cheng1 May 12, 2021, 2:30 a.m. UTC
Change the variable type in store_dma_desc_info_split() to fix
suspicious implicit sign extension.

Coverity issue: 370604, 370607, 370609
Fixes: 3d6cb86b0de5 (vhost: refactor async split ring functions)

Signed-off-by: Cheng Jiang <cheng1.jiang@intel.com>
---
 lib/vhost/virtio_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Xia, Chenbo May 12, 2021, 8:40 a.m. UTC | #1
> -----Original Message-----
> From: Jiang, Cheng1 <cheng1.jiang@intel.com>
> Sent: Wednesday, May 12, 2021 10:31 AM
> To: maxime.coquelin@redhat.com; Xia, Chenbo <chenbo.xia@intel.com>
> Cc: dev@dpdk.org; Jiang, Cheng1 <cheng1.jiang@intel.com>
> Subject: [PATCH] vhost: fix unintended sign extension in async split ring
> 
> Change the variable type in store_dma_desc_info_split() to fix
> suspicious implicit sign extension.
> 
> Coverity issue: 370604, 370607, 370609
> Fixes: 3d6cb86b0de5 (vhost: refactor async split ring functions)

Miss "" here. Will add them when applying.

> 
> Signed-off-by: Cheng Jiang <cheng1.jiang@intel.com>
> ---
>  lib/vhost/virtio_net.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
> index 8e36f4c340..9137a9923b 100644
> --- a/lib/vhost/virtio_net.c
> +++ b/lib/vhost/virtio_net.c
> @@ -1474,7 +1474,7 @@ static __rte_always_inline void
>  store_dma_desc_info_split(struct vring_used_elem *s_ring, struct
> vring_used_elem *d_ring,
>  		uint16_t ring_size, uint16_t s_idx, uint16_t d_idx, uint16_t count)
>  {
> -	uint16_t elem_size = sizeof(struct vring_used_elem);
> +	size_t elem_size = sizeof(struct vring_used_elem);
> 
>  	if (d_idx + count <= ring_size) {
>  		rte_memcpy(d_ring + d_idx, s_ring + s_idx, count * elem_size);
> --
> 2.29.2

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Xia, Chenbo May 12, 2021, 8:42 a.m. UTC | #2
> -----Original Message-----
> From: Jiang, Cheng1 <cheng1.jiang@intel.com>
> Sent: Wednesday, May 12, 2021 10:31 AM
> To: maxime.coquelin@redhat.com; Xia, Chenbo <chenbo.xia@intel.com>
> Cc: dev@dpdk.org; Jiang, Cheng1 <cheng1.jiang@intel.com>
> Subject: [PATCH] vhost: fix unintended sign extension in async split ring
> 
> Change the variable type in store_dma_desc_info_split() to fix
> suspicious implicit sign extension.
> 
> Coverity issue: 370604, 370607, 370609
> Fixes: 3d6cb86b0de5 (vhost: refactor async split ring functions)
> 
> Signed-off-by: Cheng Jiang <cheng1.jiang@intel.com>
> ---
>  lib/vhost/virtio_net.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
> index 8e36f4c340..9137a9923b 100644
> --- a/lib/vhost/virtio_net.c
> +++ b/lib/vhost/virtio_net.c
> @@ -1474,7 +1474,7 @@ static __rte_always_inline void
>  store_dma_desc_info_split(struct vring_used_elem *s_ring, struct
> vring_used_elem *d_ring,
>  		uint16_t ring_size, uint16_t s_idx, uint16_t d_idx, uint16_t count)
>  {
> -	uint16_t elem_size = sizeof(struct vring_used_elem);
> +	size_t elem_size = sizeof(struct vring_used_elem);
> 
>  	if (d_idx + count <= ring_size) {
>  		rte_memcpy(d_ring + d_idx, s_ring + s_idx, count * elem_size);
> --
> 2.29.2

Applied to next-virtio/main with commit log fixed. Thanks
diff mbox series

Patch

diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index 8e36f4c340..9137a9923b 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -1474,7 +1474,7 @@  static __rte_always_inline void
 store_dma_desc_info_split(struct vring_used_elem *s_ring, struct vring_used_elem *d_ring,
 		uint16_t ring_size, uint16_t s_idx, uint16_t d_idx, uint16_t count)
 {
-	uint16_t elem_size = sizeof(struct vring_used_elem);
+	size_t elem_size = sizeof(struct vring_used_elem);
 
 	if (d_idx + count <= ring_size) {
 		rte_memcpy(d_ring + d_idx, s_ring + s_idx, count * elem_size);