]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
block/nvme: Extract nvme_free_queue() from nvme_free_queue_pair()
authorPhilippe Mathieu-Daudé <philmd@redhat.com>
Wed, 6 Oct 2021 16:49:29 +0000 (18:49 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 2 Nov 2021 14:49:13 +0000 (15:49 +0100)
Instead of duplicating code, extract the common helper to free
a single queue.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20211006164931.172349-4-philmd@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/nvme.c

index 0c94799a5416000d70256cb305b3dca0ea62effc..e4f336d79c26c815f004460893ecc51adb9958f0 100644 (file)
@@ -183,15 +183,20 @@ static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
     return r == 0;
 }
 
+static void nvme_free_queue(NVMeQueue *q)
+{
+    qemu_vfree(q->queue);
+}
+
 static void nvme_free_queue_pair(NVMeQueuePair *q)
 {
     trace_nvme_free_queue_pair(q->index, q, &q->cq, &q->sq);
     if (q->completion_bh) {
         qemu_bh_delete(q->completion_bh);
     }
+    nvme_free_queue(&q->sq);
+    nvme_free_queue(&q->cq);
     qemu_vfree(q->prp_list_pages);
-    qemu_vfree(q->sq.queue);
-    qemu_vfree(q->cq.queue);
     qemu_mutex_destroy(&q->lock);
     g_free(q);
 }