cifs: don't dereference smb_file_target before null check
[platform/kernel/linux-rpi.git] / fs / cifs / cifsfs.c
index 7065426..fb32f3d 100644 (file)
@@ -981,8 +981,8 @@ static int cifs_clone_file_range(struct file *src_file, loff_t off,
        struct inode *src_inode = file_inode(src_file);
        struct inode *target_inode = file_inode(dst_file);
        struct cifsFileInfo *smb_file_src = src_file->private_data;
-       struct cifsFileInfo *smb_file_target = dst_file->private_data;
-       struct cifs_tcon *target_tcon = tlink_tcon(smb_file_target->tlink);
+       struct cifsFileInfo *smb_file_target;
+       struct cifs_tcon *target_tcon;
        unsigned int xid;
        int rc;
 
@@ -996,6 +996,9 @@ static int cifs_clone_file_range(struct file *src_file, loff_t off,
                goto out;
        }
 
+       smb_file_target = dst_file->private_data;
+       target_tcon = tlink_tcon(smb_file_target->tlink);
+
        /*
         * Note: cifs case is easier than btrfs since server responsible for
         * checks for proper open modes and file type and if it wants