1be5c7
From c10ef6f79d4a4c8ccc5901b25234501c621e4e04 Mon Sep 17 00:00:00 2001
1be5c7
From: Si-Wei Liu <si-wei.liu@oracle.com>
1be5c7
Date: Fri, 6 May 2022 19:28:14 -0700
1be5c7
Subject: [PATCH 16/24] vhost-vdpa: fix improper cleanup in net_init_vhost_vdpa
1be5c7
MIME-Version: 1.0
1be5c7
Content-Type: text/plain; charset=UTF-8
1be5c7
Content-Transfer-Encoding: 8bit
1be5c7
1be5c7
RH-Author: Jason Wang <jasowang@redhat.com>
1be5c7
RH-MergeRequest: 187: Multiqueue fixes for vhost-vDPA
1be5c7
RH-Commit: [3/7] b3b658dcb4695defe1fdb199570fb984291e8e21
1be5c7
RH-Bugzilla: 2069946
1be5c7
RH-Acked-by: Eugenio PĂ©rez <eperezma@redhat.com>
1be5c7
RH-Acked-by: Cindy Lu <lulu@redhat.com>
1be5c7
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
1be5c7
1be5c7
... such that no memory leaks on dangling net clients in case of
1be5c7
error.
1be5c7
1be5c7
Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
1be5c7
Acked-by: Jason Wang <jasowang@redhat.com>
1be5c7
Message-Id: <1651890498-24478-4-git-send-email-si-wei.liu@oracle.com>
1be5c7
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
1be5c7
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1be5c7
(cherry picked from commit 9bd055073e375c8a0d7ebce925e05d914d69fc7f)
1be5c7
Signed-off-by: Jason Wang <jasowang@redhat.com>
1be5c7
---
1be5c7
 net/vhost-vdpa.c | 4 +++-
1be5c7
 1 file changed, 3 insertions(+), 1 deletion(-)
1be5c7
1be5c7
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
1be5c7
index 25dd6dd975..814f704687 100644
1be5c7
--- a/net/vhost-vdpa.c
1be5c7
+++ b/net/vhost-vdpa.c
1be5c7
@@ -306,7 +306,9 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
1be5c7
 
1be5c7
 err:
1be5c7
     if (i) {
1be5c7
-        qemu_del_net_client(ncs[0]);
1be5c7
+        for (i--; i >= 0; i--) {
1be5c7
+            qemu_del_net_client(ncs[i]);
1be5c7
+        }
1be5c7
     }
1be5c7
     qemu_close(vdpa_device_fd);
1be5c7
     g_free(ncs);
1be5c7
-- 
1be5c7
2.35.3
1be5c7