[v3] vhost: fix missing device pointer validity check
diff mbox series

Message ID 20200721032304.3372145-1-patrick.fu@intel.com
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • [v3] vhost: fix missing device pointer validity check
Related show

Checks

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

Commit Message

Patrick Fu July 21, 2020, 3:23 a.m. UTC
From: Patrick Fu <patrick.fu@intel.com>

This patch adds the check of dev pointer in vhost async enqueue
completion poll. If a NULL dev pointer detected, the poll function
returns immediately.

Coverity issue: 360839
Fixes: cd6760da1076 ("vhost: introduce async enqueue for split ring")

Signed-off-by: Patrick Fu <patrick.fu@intel.com>
---
v2:
  - change fixline number
v3:
 - revise commit message title

 lib/librte_vhost/virtio_net.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Maxime Coquelin July 21, 2020, 8:36 a.m. UTC | #1
On 7/21/20 5:23 AM, patrick.fu@intel.com wrote:
> From: Patrick Fu <patrick.fu@intel.com>
> 
> This patch adds the check of dev pointer in vhost async enqueue
> completion poll. If a NULL dev pointer detected, the poll function
> returns immediately.
> 
> Coverity issue: 360839
> Fixes: cd6760da1076 ("vhost: introduce async enqueue for split ring")
> 
> Signed-off-by: Patrick Fu <patrick.fu@intel.com>
> ---
> v2:
>   - change fixline number
> v3:
>  - revise commit message title
> 
>  lib/librte_vhost/virtio_net.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index 1d0be3dd4..235c31e28 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -1635,6 +1635,9 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
>  	uint16_t start_idx, pkts_idx, vq_size;
>  	uint64_t *async_pending_info;
>  
> +	if (!dev)
> +		return 0;
> +
>  	VHOST_LOG_DATA(DEBUG, "(%d) %s\n", dev->vid, __func__);
>  	if (unlikely(!is_valid_virt_queue_idx(queue_id, 0, dev->nr_vring))) {
>  		VHOST_LOG_DATA(ERR, "(%d) %s: invalid virtqueue idx %d.\n",
> 

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

Thanks,
Maxime
Ferruh Yigit July 21, 2020, 2:51 p.m. UTC | #2
On 7/21/2020 9:36 AM, Maxime Coquelin wrote:
> 
> 
> On 7/21/20 5:23 AM, patrick.fu@intel.com wrote:
>> From: Patrick Fu <patrick.fu@intel.com>
>>
>> This patch adds the check of dev pointer in vhost async enqueue
>> completion poll. If a NULL dev pointer detected, the poll function
>> returns immediately.
>>
>> Coverity issue: 360839
>> Fixes: cd6760da1076 ("vhost: introduce async enqueue for split ring")
>>
>> Signed-off-by: Patrick Fu <patrick.fu@intel.com>
> 
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> 

Applied to dpdk-next-net/master, thanks.

Patch
diff mbox series

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 1d0be3dd4..235c31e28 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1635,6 +1635,9 @@  uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
 	uint16_t start_idx, pkts_idx, vq_size;
 	uint64_t *async_pending_info;
 
+	if (!dev)
+		return 0;
+
 	VHOST_LOG_DATA(DEBUG, "(%d) %s\n", dev->vid, __func__);
 	if (unlikely(!is_valid_virt_queue_idx(queue_id, 0, dev->nr_vring))) {
 		VHOST_LOG_DATA(ERR, "(%d) %s: invalid virtqueue idx %d.\n",