thebeanogamer / rpms / qemu-kvm

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