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