smb2_set_file_info(struct inode *inode, const char *full_path,
                   FILE_BASIC_INFO *buf, const unsigned int xid)
 {
-       struct cifs_open_parms oparms;
+       struct kvec in_iov = { .iov_base = buf, .iov_len = sizeof(*buf), };
        struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+       struct cifsFileInfo *cfile = NULL;
+       struct cifs_open_parms oparms;
        struct tcon_link *tlink;
        struct cifs_tcon *tcon;
-       struct cifsFileInfo *cfile;
-       struct kvec in_iov = { .iov_base = buf, .iov_len = sizeof(*buf), };
-       int rc;
-
-       if ((buf->CreationTime == 0) && (buf->LastAccessTime == 0) &&
-           (buf->LastWriteTime == 0) && (buf->ChangeTime == 0) &&
-           (buf->Attributes == 0))
-               return 0; /* would be a no op, no sense sending this */
+       int rc = 0;
 
        tlink = cifs_sb_tlink(cifs_sb);
        if (IS_ERR(tlink))
                return PTR_ERR(tlink);
        tcon = tlink_tcon(tlink);
 
-       cifs_get_writable_path(tcon, full_path, FIND_WR_ANY, &cfile);
+       if ((buf->CreationTime == 0) && (buf->LastAccessTime == 0) &&
+           (buf->LastWriteTime == 0) && (buf->ChangeTime == 0)) {
+               if (buf->Attributes == 0)
+                       goto out; /* would be a no op, no sense sending this */
+               cifs_get_writable_path(tcon, full_path, FIND_WR_ANY, &cfile);
+       }
+
        oparms = CIFS_OPARMS(cifs_sb, tcon, full_path, FILE_WRITE_ATTRIBUTES,
                             FILE_OPEN, 0, ACL_NO_MODE);
        rc = smb2_compound_op(xid, tcon, cifs_sb,
                              full_path, &oparms, &in_iov,
                              &(int){SMB2_OP_SET_INFO}, 1,
                              cfile, NULL, NULL, NULL);
+out:
        cifs_put_tlink(tlink);
        return rc;
 }