vhost: fix unchecked return value

Message ID 20220623010858.951367-1-jiayu.hu@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series vhost: fix unchecked return value |

Checks

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

Commit Message

Hu, Jiayu June 23, 2022, 1:08 a.m. UTC
  This patch checks the return value of rte_dma_info_get()
called in rte_vhost_async_dma_configure().

Coverity issue: 379066
Fixes: 53d3f4778c1d ("vhost: integrate dmadev in asynchronous data-path")

Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
---
 lib/vhost/vhost.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Chenbo Xia June 23, 2022, 2:44 a.m. UTC | #1
Hi Jiayu,

> -----Original Message-----
> From: Hu, Jiayu <jiayu.hu@intel.com>
> Sent: Thursday, June 23, 2022 9:09 AM
> To: dev@dpdk.org
> Cc: maxime.coquelin@redhat.com; Xia, Chenbo <chenbo.xia@intel.com>; Hu,
> Jiayu <jiayu.hu@intel.com>
> Subject: [PATCH] vhost: fix unchecked return value
> 
> This patch checks the return value of rte_dma_info_get()
> called in rte_vhost_async_dma_configure().
> 
> Coverity issue: 379066
> Fixes: 53d3f4778c1d ("vhost: integrate dmadev in asynchronous data-path")

Missed CC stable tag

With this fixed:

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>

> 
> Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
> ---
>  lib/vhost/vhost.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
> index b14521e4d1..70c04c036e 100644
> --- a/lib/vhost/vhost.c
> +++ b/lib/vhost/vhost.c
> @@ -1868,7 +1868,11 @@ rte_vhost_async_dma_configure(int16_t dma_id,
> uint16_t vchan_id)
>  		return -1;
>  	}
> 
> -	rte_dma_info_get(dma_id, &info);
> +	if (rte_dma_info_get(dma_id, &info) != 0) {
> +		VHOST_LOG_CONFIG(ERR, "Fail to get DMA %d information.\n",
> dma_id);
> +		return -1;
> +	}
> +
>  	if (vchan_id >= info.max_vchans) {
>  		VHOST_LOG_CONFIG(ERR, "Invalid DMA %d vChannel %u.\n", dma_id,
> vchan_id);
>  		return -1;
> --
> 2.25.1
  

Patch

diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index b14521e4d1..70c04c036e 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -1868,7 +1868,11 @@  rte_vhost_async_dma_configure(int16_t dma_id, uint16_t vchan_id)
 		return -1;
 	}
 
-	rte_dma_info_get(dma_id, &info);
+	if (rte_dma_info_get(dma_id, &info) != 0) {
+		VHOST_LOG_CONFIG(ERR, "Fail to get DMA %d information.\n", dma_id);
+		return -1;
+	}
+
 	if (vchan_id >= info.max_vchans) {
 		VHOST_LOG_CONFIG(ERR, "Invalid DMA %d vChannel %u.\n", dma_id, vchan_id);
 		return -1;