]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs/cifs: Fix resource leak
authorKhaled ROMDHANI <khaledromdhani216@gmail.com>
Tue, 4 May 2021 15:38:55 +0000 (16:38 +0100)
committerSteve French <stfrench@microsoft.com>
Tue, 4 May 2021 16:53:15 +0000 (11:53 -0500)
The -EIO error return path is leaking memory allocated
to page. Fix this by moving the allocation block after
the check of cifs_forced_shutdown.

Addresses-Coverity: ("Resource leak")
Fixes: 087f757b0129 ("cifs: add shutdown support")
Signed-off-by: Khaled ROMDHANI <khaledromdhani216@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/link.c

index 1cbe7ec7372838783b6e880e11db2b6f32db121e..970fcf2adb08c3ffa7992b6924974e19811ede07 100644 (file)
@@ -683,12 +683,16 @@ cifs_symlink(struct user_namespace *mnt_userns, struct inode *inode,
        struct tcon_link *tlink;
        struct cifs_tcon *pTcon;
        const char *full_path;
-       void *page = alloc_dentry_path();
+       void *page;
        struct inode *newinode = NULL;
 
        if (unlikely(cifs_forced_shutdown(cifs_sb)))
                return -EIO;
 
+       page = alloc_dentry_path();
+       if (!page)
+               return -ENOMEM;
+
        xid = get_xid();
 
        tlink = cifs_sb_tlink(cifs_sb);