Skip to contentSkip to conversation

vhost: fix missing descriptor reclaim on copy_to_iter failure

PATCH New [email protected] 1 participant 1 message Aug 6, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: fix missing descriptor reclaim on copy_to_iter failure

From: Henry Martin <[email protected]>

If copy_to_iter(&hdr, sizeof(hdr), &fixup) fails, the descriptor is not reclaimed via vhost_discard_vq_desc(), leading to potential resource leaks.

Fix it by explicitly calling vhost_discard_vq_desc() on failure.

Fixes 4c5a84421c7d ("vhost: cleanup iterator update logic")
---
 drivers/vhost/net.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vhost/net.c +1 -0
index 6edac0c1ba9b..7b4be344b8af 100644
@@ -1238,6 +1238,7 @@ static void handle_rx(struct vhost_net *net)
 					 &fixup) != sizeof(hdr)) {
 				vq_err(vq, "Unable to write vnet_hdr "
 				       "at addr %p\n", vq->iov->iov_base);
+				vhost_discard_vq_desc(vq, headcount);
 				goto out;
 			}
 		} else {
Signature · 1 line
2.41.3