Blame 0093-Virtiofsd-fix-memory-leak-on-fuse-queueinfo.patch

1d442b
From: Liu Bo <bo.liu@linux.alibaba.com>
1d442b
Date: Mon, 27 Jan 2020 19:02:02 +0000
1d442b
Subject: [PATCH] Virtiofsd: fix memory leak on fuse queueinfo
1d442b
1d442b
For fuse's queueinfo, both queueinfo array and queueinfos are allocated in
1d442b
fv_queue_set_started() but not cleaned up when the daemon process quits.
1d442b
1d442b
This fixes the leak in proper places.
1d442b
1d442b
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
1d442b
Signed-off-by: Eric Ren <renzhen@linux.alibaba.com>
1d442b
Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
1d442b
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1d442b
(cherry picked from commit 740b0b700a6338a1cf60c26229651ac5f6724944)
1d442b
---
1d442b
 tools/virtiofsd/fuse_virtio.c | 8 ++++++++
1d442b
 1 file changed, 8 insertions(+)
1d442b
1d442b
diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
1d442b
index b7948def27..fb8d6d1379 100644
1d442b
--- a/tools/virtiofsd/fuse_virtio.c
1d442b
+++ b/tools/virtiofsd/fuse_virtio.c
1d442b
@@ -625,6 +625,8 @@ static void fv_queue_cleanup_thread(struct fv_VuDev *vud, int qidx)
1d442b
     }
1d442b
     close(ourqi->kill_fd);
1d442b
     ourqi->kick_fd = -1;
1d442b
+    free(vud->qi[qidx]);
1d442b
+    vud->qi[qidx] = NULL;
1d442b
 }
1d442b
 
1d442b
 /* Callback from libvhost-user on start or stop of a queue */
1d442b
@@ -884,6 +886,12 @@ int virtio_session_mount(struct fuse_session *se)
1d442b
 void virtio_session_close(struct fuse_session *se)
1d442b
 {
1d442b
     close(se->vu_socketfd);
1d442b
+
1d442b
+    if (!se->virtio_dev) {
1d442b
+        return;
1d442b
+    }
1d442b
+
1d442b
+    free(se->virtio_dev->qi);
1d442b
     free(se->virtio_dev);
1d442b
     se->virtio_dev = NULL;
1d442b
 }