Skip to contentSkip to conversation

hw: virtio-pmem: detach the element fromt the virtqueue when error occurs

PATCH New Li Qiang 1 participant 1 message Sep 21, 2020

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 hw: virtio-pmem: detach the element fromt the virtqueue when error occurs

If error occurs while processing the virtio request we should call 'virtqueue_detach_element' to detach the element from the virtqueue before free the elem.

Fixes 5f503cd9f3 ("virtio-pmem: add virtio device")
---
 hw/virtio/virtio-pmem.c | 1 +
 1 file changed, 1 insertion(+)
hw/virtio/virtio-pmem.c +1 -0
index 1e0c137497..ddb0125901 100644
@@ -77,6 +77,7 @@ static void virtio_pmem_flush(VirtIODevice *vdev, VirtQueue *vq)
 
     if (req_data->elem.out_num < 1 || req_data->elem.in_num < 1) {
         virtio_error(vdev, "virtio-pmem request not proper");
+        virtqueue_detach_element(vq, (VirtQueueElement *)req_data, 0);
         g_free(req_data);
         return;
     }
Signature · 1 line
2.17.1