vhost: fix unchecked return value
Checks
Commit Message
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
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
@@ -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;