]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cifs: Fix xid leak in cifs_get_file_info_unix()
authorZhang Xiaoxu <zhangxiaoxu5@huawei.com>
Mon, 17 Oct 2022 14:45:25 +0000 (22:45 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:26:54 +0000 (13:26 +0100)
commit 10269f13257d4eb6061d09ccce61666316df9838 upstream.

If stardup the symlink target failed, should free the xid,
otherwise the xid will be leaked.

Fixes: 76894f3e2f71 ("cifs: improve symlink handling for smb2+")
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/cifs/inode.c

index c1ea821899f8dc211fe3f86a65fabf62d6fd8436..60daa6fffce5c0272e4a3382215ad00107228be6 100644 (file)
@@ -368,8 +368,10 @@ cifs_get_file_info_unix(struct file *filp)
 
        if (cfile->symlink_target) {
                fattr.cf_symlink_target = kstrdup(cfile->symlink_target, GFP_KERNEL);
-               if (!fattr.cf_symlink_target)
-                       return -ENOMEM;
+               if (!fattr.cf_symlink_target) {
+                       rc = -ENOMEM;
+                       goto cifs_gfiunix_out;
+               }
        }
 
        rc = CIFSSMBUnixQFileInfo(xid, tcon, cfile->fid.netfid, &find_data);