diff mbox series

vhost: initialize postcopy ufd properly

Message ID 20181024093948.9539-1-tiwei.bie@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers show
Series vhost: initialize postcopy ufd properly | expand

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Tiwei Bie Oct. 24, 2018, 9:39 a.m. UTC
Currently, postcopy_ufd is initialized to 0 implicitly, so fd 0
could be closed unexpectedly by vhost_backend_cleanup(). Fix this
issue by initializing postcopy_ufd to -1 explicitly.

Fixes: 9eefef3b5970 ("vhost: introduce postcopy advise message")

Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
 lib/librte_vhost/vhost.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Maxime Coquelin Oct. 24, 2018, 10:20 a.m. UTC | #1
On 10/24/18 11:39 AM, Tiwei Bie wrote:
> Currently, postcopy_ufd is initialized to 0 implicitly, so fd 0
> could be closed unexpectedly by vhost_backend_cleanup(). Fix this
> issue by initializing postcopy_ufd to -1 explicitly.
> 
> Fixes: 9eefef3b5970 ("vhost: introduce postcopy advise message")
> 
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> ---
>   lib/librte_vhost/vhost.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
> index 047ee535c..70ac6bc9c 100644
> --- a/lib/librte_vhost/vhost.c
> +++ b/lib/librte_vhost/vhost.c
> @@ -344,6 +344,7 @@ vhost_new_device(void)
>   	dev->flags = VIRTIO_DEV_BUILTIN_VIRTIO_NET;
>   	dev->slave_req_fd = -1;
>   	dev->vdpa_dev_id = -1;
> +	dev->postcopy_ufd = -1;
>   	rte_spinlock_init(&dev->slave_req_lock);
>   
>   	return i;
> 

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

Thanks!
Maxime
Maxime Coquelin Oct. 24, 2018, 10:51 a.m. UTC | #2
On 10/24/18 11:39 AM, Tiwei Bie wrote:
> Currently, postcopy_ufd is initialized to 0 implicitly, so fd 0
> could be closed unexpectedly by vhost_backend_cleanup(). Fix this
> issue by initializing postcopy_ufd to -1 explicitly.
> 
> Fixes: 9eefef3b5970 ("vhost: introduce postcopy advise message")
> 
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> ---
>   lib/librte_vhost/vhost.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
> index 047ee535c..70ac6bc9c 100644
> --- a/lib/librte_vhost/vhost.c
> +++ b/lib/librte_vhost/vhost.c
> @@ -344,6 +344,7 @@ vhost_new_device(void)
>   	dev->flags = VIRTIO_DEV_BUILTIN_VIRTIO_NET;
>   	dev->slave_req_fd = -1;
>   	dev->vdpa_dev_id = -1;
> +	dev->postcopy_ufd = -1;
>   	rte_spinlock_init(&dev->slave_req_lock);
>   
>   	return i;
> 

Applied to dpdk-next-virtio/master.

Thanks,
Maxime
diff mbox series

Patch

diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 047ee535c..70ac6bc9c 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -344,6 +344,7 @@  vhost_new_device(void)
 	dev->flags = VIRTIO_DEV_BUILTIN_VIRTIO_NET;
 	dev->slave_req_fd = -1;
 	dev->vdpa_dev_id = -1;
+	dev->postcopy_ufd = -1;
 	rte_spinlock_init(&dev->slave_req_lock);
 
 	return i;