[v2] vhost: fix missing null dev pointer check
diff mbox series

Message ID 20200716153758.2895041-1-patrick.fu@intel.com
State Changes Requested
Delegated to: Maxime Coquelin
Headers show
Series
  • [v2] vhost: fix missing null dev pointer check
Related show

Checks

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

Commit Message

Fu, Patrick July 16, 2020, 3:37 p.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

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

Comments

Chenbo Xia July 17, 2020, 8:08 a.m. UTC | #1
> -----Original Message-----
> From: Fu, Patrick <patrick.fu@intel.com>
> Sent: Thursday, July 16, 2020 11:38 PM
> To: dev@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo
> <chenbo.xia@intel.com>
> Cc: Fu, Patrick <patrick.fu@intel.com>
> Subject: [PATCH v2] vhost: fix missing null dev pointer check
> 
> 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
> 
>  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",
> --
> 2.18.4

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Ferruh Yigit July 17, 2020, 1:10 p.m. UTC | #2
On 7/17/2020 9:08 AM, Xia, Chenbo wrote:
> 
>> -----Original Message-----
>> From: Fu, Patrick <patrick.fu@intel.com>
>> Sent: Thursday, July 16, 2020 11:38 PM
>> To: dev@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo
>> <chenbo.xia@intel.com>
>> Cc: Fu, Patrick <patrick.fu@intel.com>
>> Subject: [PATCH v2] vhost: fix missing null dev pointer check
>>
>> 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: Chenbo Xia <chenbo.xia@intel.com>
> 

Applied to dpdk-next-net/master, thanks.
Maxime Coquelin July 20, 2020, 3:55 p.m. UTC | #3
What about below title (we try to avoid passing variable names in commit
titles)?
vhost: fix missing device pointer validity check

On 7/16/20 5:37 PM, 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
> 
>  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",
>
Ferruh Yigit July 20, 2020, 4:49 p.m. UTC | #4
On 7/20/2020 4:55 PM, Maxime Coquelin wrote:
> What about below title (we try to avoid passing variable names in commit
> titles)?
> vhost: fix missing device pointer validity check

Existing commit dropped from next-net and patchwork status updated.

> 
> On 7/16/20 5:37 PM, 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>

<...>

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",