thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ddf19c
From 99ff67682ef7c5659bdc9836008541861ae313d5 Mon Sep 17 00:00:00 2001
ddf19c
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
ddf19c
Date: Mon, 27 Jan 2020 19:01:56 +0100
ddf19c
Subject: [PATCH 085/116] virtiofsd: cleanup allocated resource in se
ddf19c
MIME-Version: 1.0
ddf19c
Content-Type: text/plain; charset=UTF-8
ddf19c
Content-Transfer-Encoding: 8bit
ddf19c
ddf19c
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
Message-id: <20200127190227.40942-82-dgilbert@redhat.com>
ddf19c
Patchwork-id: 93533
ddf19c
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 081/112] virtiofsd: cleanup allocated resource in se
ddf19c
Bugzilla: 1694164
ddf19c
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ddf19c
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ddf19c
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
ddf19c
ddf19c
From: Liu Bo <bo.liu@linux.alibaba.com>
ddf19c
ddf19c
This cleans up unfreed resources in se on quiting, including
ddf19c
se->virtio_dev, se->vu_socket_path, se->vu_socketfd.
ddf19c
ddf19c
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
ddf19c
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
ddf19c
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
(cherry picked from commit 61cfc44982e566c33b9d5df17858e4d5ae373873)
ddf19c
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ddf19c
---
ddf19c
 tools/virtiofsd/fuse_lowlevel.c | 7 +++++++
ddf19c
 tools/virtiofsd/fuse_virtio.c   | 7 +++++++
ddf19c
 tools/virtiofsd/fuse_virtio.h   | 2 +-
ddf19c
 3 files changed, 15 insertions(+), 1 deletion(-)
ddf19c
ddf19c
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
ddf19c
index 65f91da..440508a 100644
ddf19c
--- a/tools/virtiofsd/fuse_lowlevel.c
ddf19c
+++ b/tools/virtiofsd/fuse_lowlevel.c
ddf19c
@@ -2532,6 +2532,13 @@ void fuse_session_destroy(struct fuse_session *se)
ddf19c
     if (se->fd != -1) {
ddf19c
         close(se->fd);
ddf19c
     }
ddf19c
+
ddf19c
+    if (se->vu_socket_path) {
ddf19c
+        virtio_session_close(se);
ddf19c
+        free(se->vu_socket_path);
ddf19c
+        se->vu_socket_path = NULL;
ddf19c
+    }
ddf19c
+
ddf19c
     free(se);
ddf19c
 }
ddf19c
 
ddf19c
diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
ddf19c
index 7a8774a..e7bd772 100644
ddf19c
--- a/tools/virtiofsd/fuse_virtio.c
ddf19c
+++ b/tools/virtiofsd/fuse_virtio.c
ddf19c
@@ -833,3 +833,10 @@ int virtio_session_mount(struct fuse_session *se)
ddf19c
 
ddf19c
     return 0;
ddf19c
 }
ddf19c
+
ddf19c
+void virtio_session_close(struct fuse_session *se)
ddf19c
+{
ddf19c
+    close(se->vu_socketfd);
ddf19c
+    free(se->virtio_dev);
ddf19c
+    se->virtio_dev = NULL;
ddf19c
+}
ddf19c
diff --git a/tools/virtiofsd/fuse_virtio.h b/tools/virtiofsd/fuse_virtio.h
ddf19c
index cc676b9..1116840 100644
ddf19c
--- a/tools/virtiofsd/fuse_virtio.h
ddf19c
+++ b/tools/virtiofsd/fuse_virtio.h
ddf19c
@@ -19,7 +19,7 @@
ddf19c
 struct fuse_session;
ddf19c
 
ddf19c
 int virtio_session_mount(struct fuse_session *se);
ddf19c
-
ddf19c
+void virtio_session_close(struct fuse_session *se);
ddf19c
 int virtio_loop(struct fuse_session *se);
ddf19c
 
ddf19c
 
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c