diff mbox series

[4/5] virtiofsd: fix inode nlookup leaks

Message ID 20190731161006.9447-5-stefanha@redhat.com (mailing list archive)
State New, archived
Headers show
Series virtiofsd: multithreading preparation part 2 | expand

Commit Message

Stefan Hajnoczi July 31, 2019, 4:10 p.m. UTC
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@redhat.com>
---
 contrib/virtiofsd/passthrough_ll.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

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;
 }