[Virtio-fs] [PATCH 4/5] virtiofsd: fix inode nlookup leaks

Stefan Hajnoczi stefanha at redhat.com
Wed Jul 31 16:10:05 UTC 2019


utimensat_empty() and linkat_empty_nofollow() must unref the parent
directory inode that was obtained from lo_parent_and_name().

Signed-off-by: Stefan Hajnoczi <stefanha at redhat.com>
---
 contrib/virtiofsd/passthrough_ll.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthrough_ll.c
index 135123366a..125e9d9f96 100644
--- a/contrib/virtiofsd/passthrough_ll.c
+++ b/contrib/virtiofsd/passthrough_ll.c
@@ -567,8 +567,10 @@ static int utimensat_empty(struct lo_data *lo, struct lo_inode *inode,
 
 fallback:
 	res = lo_parent_and_name(lo, inode, path, &parent);
-	if (res != -1)
+	if (res != -1) {
 		res = utimensat(parent->fd, path, tv, AT_SYMLINK_NOFOLLOW);
+		unref_inode(lo, parent, 1);
+	}
 
 	return res;
 }
@@ -1024,8 +1026,10 @@ static int linkat_empty_nofollow(struct lo_data *lo, struct lo_inode *inode,
 
 fallback:
 	res = lo_parent_and_name(lo, inode, path, &parent);
-	if (res != -1)
+	if (res != -1) {
 		res = linkat(parent->fd, path, dfd, name, 0);
+		unref_inode(lo, parent, 1);
+	}
 
 	return res;
 }
-- 
2.21.0




More information about the Virtio-fs mailing list