[1/4] vhost: fix uninitialized vhost queue

Message ID 1615985773-406787-2-git-send-email-jiayu.hu@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series Refactor async vhost control path |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Hu, Jiayu March 17, 2021, 12:56 p.m. UTC
  This patch allocates vhost queue by rte_zmalloc() to avoid
undefined values.

Fixes: 8acd7c213353 ("vhost: fix virtqueues metadata allocation")

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

Comments

Maxime Coquelin March 26, 2021, 3:14 p.m. UTC | #1
On 3/17/21 1:56 PM, Jiayu Hu wrote:
> This patch allocates vhost queue by rte_zmalloc() to avoid
> undefined values.
> 
> Fixes: 8acd7c213353 ("vhost: fix virtqueues metadata allocation")

This is not the right commit. rte_malloc was used prior to it.

> Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
> ---
>  lib/librte_vhost/vhost.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
> index 52ab93d..f6fd001 100644
> --- a/lib/librte_vhost/vhost.c
> +++ b/lib/librte_vhost/vhost.c
> @@ -598,7 +598,7 @@ alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
>  		if (dev->virtqueue[i])
>  			continue;
>  
> -		vq = rte_malloc(NULL, sizeof(struct vhost_virtqueue), 0);
> +		vq = rte_zmalloc(NULL, sizeof(struct vhost_virtqueue), 0);
>  		if (vq == NULL) {
>  			VHOST_LOG_CONFIG(ERR,
>  				"Failed to allocate memory for vring:%u.\n", i);
>
  

Patch

diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 52ab93d..f6fd001 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -598,7 +598,7 @@  alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
 		if (dev->virtqueue[i])
 			continue;
 
-		vq = rte_malloc(NULL, sizeof(struct vhost_virtqueue), 0);
+		vq = rte_zmalloc(NULL, sizeof(struct vhost_virtqueue), 0);
 		if (vq == NULL) {
 			VHOST_LOG_CONFIG(ERR,
 				"Failed to allocate memory for vring:%u.\n", i);