902636
From ceb6d97674b8bc9a072db1be4167411bc0ee48d7 Mon Sep 17 00:00:00 2001
902636
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
902636
Date: Mon, 27 Jan 2020 19:02:02 +0100
902636
Subject: [PATCH 091/116] Virtiofsd: fix memory leak on fuse queueinfo
902636
MIME-Version: 1.0
902636
Content-Type: text/plain; charset=UTF-8
902636
Content-Transfer-Encoding: 8bit
902636
902636
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
Message-id: <20200127190227.40942-88-dgilbert@redhat.com>
902636
Patchwork-id: 93542
902636
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 087/112] Virtiofsd: fix memory leak on fuse queueinfo
902636
Bugzilla: 1694164
902636
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
902636
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
902636
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
902636
902636
From: Liu Bo <bo.liu@linux.alibaba.com>
902636
902636
For fuse's queueinfo, both queueinfo array and queueinfos are allocated in
902636
fv_queue_set_started() but not cleaned up when the daemon process quits.
902636
902636
This fixes the leak in proper places.
902636
902636
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
902636
Signed-off-by: Eric Ren <renzhen@linux.alibaba.com>
902636
Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
902636
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
(cherry picked from commit 740b0b700a6338a1cf60c26229651ac5f6724944)
902636
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
902636
---
902636
 tools/virtiofsd/fuse_virtio.c | 8 ++++++++
902636
 1 file changed, 8 insertions(+)
902636
902636
diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
902636
index b7948de..fb8d6d1 100644
902636
--- a/tools/virtiofsd/fuse_virtio.c
902636
+++ b/tools/virtiofsd/fuse_virtio.c
902636
@@ -625,6 +625,8 @@ static void fv_queue_cleanup_thread(struct fv_VuDev *vud, int qidx)
902636
     }
902636
     close(ourqi->kill_fd);
902636
     ourqi->kick_fd = -1;
902636
+    free(vud->qi[qidx]);
902636
+    vud->qi[qidx] = NULL;
902636
 }
902636
 
902636
 /* Callback from libvhost-user on start or stop of a queue */
902636
@@ -884,6 +886,12 @@ int virtio_session_mount(struct fuse_session *se)
902636
 void virtio_session_close(struct fuse_session *se)
902636
 {
902636
     close(se->vu_socketfd);
902636
+
902636
+    if (!se->virtio_dev) {
902636
+        return;
902636
+    }
902636
+
902636
+    free(se->virtio_dev->qi);
902636
     free(se->virtio_dev);
902636
     se->virtio_dev = NULL;
902636
 }
902636
-- 
902636
1.8.3.1
902636