kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vhost: initialize vq->nheads properly
@ 2025-07-29  7:39 Jason Wang
  2025-07-29  8:09 ` Dawid Osuchowski
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Jason Wang @ 2025-07-29  7:39 UTC (permalink / raw)
  To: mst, jasowang, eperezma
  Cc: kvm, virtualization, netdev, linux-kernel, sgarzare, will,
	JAEHOON KIM, Breno Leitao

Commit 7918bb2d19c9 ("vhost: basic in order support") introduces
vq->nheads to store the number of batched used buffers per used elem
but it forgets to initialize the vq->nheads to NULL in
vhost_dev_init() this will cause kfree() that would try to free it
without be allocated if SET_OWNER is not called.

Reported-by: JAEHOON KIM <jhkim@linux.ibm.com>
Reported-by: Breno Leitao <leitao@debian.org>
Fixes: 7918bb2d19c9 ("vhost: basic in order support")
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vhost/vhost.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index a4873d116df1..b4dfe38c7008 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -615,6 +615,7 @@ void vhost_dev_init(struct vhost_dev *dev,
 		vq->log = NULL;
 		vq->indirect = NULL;
 		vq->heads = NULL;
+		vq->nheads = NULL;
 		vq->dev = dev;
 		mutex_init(&vq->mutex);
 		vhost_vq_reset(dev, vq);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-08-04 15:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-29  7:39 [PATCH] vhost: initialize vq->nheads properly Jason Wang
2025-07-29  8:09 ` Dawid Osuchowski
2025-07-29  9:11 ` Breno Leitao
2025-07-29  9:56 ` Stefano Garzarella
2025-07-29 13:51 ` JAEHOON KIM
2025-08-04  9:05 ` Jason Wang
2025-08-04 15:57   ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).