From 2fc54b812123fa9507ceba779d84f3bb5552ccb7 Mon Sep 17 00:00:00 2001 From: shivanayak Date: Mon, 9 Mar 2026 23:59:54 +0530 Subject: [PATCH] lib: fix ownership leaks in FUSE cache insert functions on malloc failure (#321) In rlc_insert and xac_insert (lib/fuse.c), both functions take ownership of a parameter (link and xattrs respectively) but fail to free it when their own malloc calls fail. Under memory pressure in a long-running FUSE process, each failed cache insertion leaks the owned resource. Co-authored-by: Claude --- lib/fuse.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/fuse.c b/lib/fuse.c index 8cc33d9c6..e45b56c06 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -1385,6 +1385,7 @@ xac_insert (guestfs_h *g, entry = malloc (sizeof *entry); if (entry == NULL) { perrorf (g, "malloc"); + guestfs_free_xattr_list (xattrs); return -1; } @@ -1393,6 +1394,7 @@ xac_insert (guestfs_h *g, if (entry->c.pathname == NULL) { perrorf (g, "malloc"); free (entry); + guestfs_free_xattr_list (xattrs); return -1; } if (STREQ (path, "/")) @@ -1418,6 +1420,7 @@ rlc_insert (guestfs_h *g, entry = malloc (sizeof *entry); if (entry == NULL) { perrorf (g, "malloc"); + free (link); return -1; } @@ -1426,6 +1429,7 @@ rlc_insert (guestfs_h *g, if (entry->c.pathname == NULL) { perrorf (g, "malloc"); free (entry); + free (link); return -1; } if (STREQ (path, "/"))