yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-virtiofsd-cleanup-allocated-resource-in-se.patch

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