Skip to contentSkip to conversation

fs/cifs: Fix resource leak

PATCH-next Khaled ROMDHANI 1 participant 1 message May 4, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

The -EIO error return path is leaking memory allocated to page. Fix this by invoking the free_dentry_path before the return.

Addresses-Coverity: ("Resource leak")

---
 fs/cifs/link.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/cifs/link.c +3 -1
index 1cbe7ec73728..1485c6095ba1 100644
@@ -686,8 +686,10 @@ cifs_symlink(struct user_namespace *mnt_userns, struct inode *inode,
 	void *page = alloc_dentry_path();
 	struct inode *newinode = NULL;
 
-	if (unlikely(cifs_forced_shutdown(cifs_sb)))
+	if (unlikely(cifs_forced_shutdown(cifs_sb))) {
+		free_dentry_path(page);
 		return -EIO;
+	}
 
 	xid = get_xid();
 
Signature · 1 line
2.17.1