Commit 66d45ca1 authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French

cifs: Check the lease context if we actually got a lease

Some servers may return that we got a lease in rsp->OplockLevel
but then in the lease context contradict this and say we got no lease
at all.  Thus we need to check the context if we have a lease.
Additionally, If we do not get a lease we need to make sure we close
the handle before we return an error to the caller.
Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Cc: stable@vger.kernel.org
Reviewed-by: default avatarBharath SM <bharathsm@microsoft.com>
Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 35235e19
...@@ -221,8 +221,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, ...@@ -221,8 +221,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
} }
goto oshr_free; goto oshr_free;
} }
cfid->is_open = true;
atomic_inc(&tcon->num_remote_opens);
o_rsp = (struct smb2_create_rsp *)rsp_iov[0].iov_base; o_rsp = (struct smb2_create_rsp *)rsp_iov[0].iov_base;
oparms.fid->persistent_fid = o_rsp->PersistentFileId; oparms.fid->persistent_fid = o_rsp->PersistentFileId;
...@@ -239,7 +238,8 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, ...@@ -239,7 +238,8 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
&oparms.fid->epoch, &oparms.fid->epoch,
oparms.fid->lease_key, &oplock, oparms.fid->lease_key, &oplock,
NULL, NULL); NULL, NULL);
if (!(oplock & SMB2_LEASE_READ_CACHING_HE))
goto oshr_free;
qi_rsp = (struct smb2_query_info_rsp *)rsp_iov[1].iov_base; qi_rsp = (struct smb2_query_info_rsp *)rsp_iov[1].iov_base;
if (le32_to_cpu(qi_rsp->OutputBufferLength) < sizeof(struct smb2_file_all_info)) if (le32_to_cpu(qi_rsp->OutputBufferLength) < sizeof(struct smb2_file_all_info))
goto oshr_free; goto oshr_free;
...@@ -262,7 +262,6 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, ...@@ -262,7 +262,6 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
cfid->dentry = dentry; cfid->dentry = dentry;
cfid->tcon = tcon; cfid->tcon = tcon;
cfid->time = jiffies; cfid->time = jiffies;
cfid->is_open = true;
cfid->has_lease = true; cfid->has_lease = true;
oshr_free: oshr_free:
...@@ -282,12 +281,17 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, ...@@ -282,12 +281,17 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
} }
spin_unlock(&cfids->cfid_list_lock); spin_unlock(&cfids->cfid_list_lock);
if (rc) { if (rc) {
if (cfid->is_open)
SMB2_close(0, cfid->tcon, cfid->fid.persistent_fid,
cfid->fid.volatile_fid);
free_cached_dir(cfid); free_cached_dir(cfid);
cfid = NULL; cfid = NULL;
} }
if (rc == 0) if (rc == 0) {
*ret_cfid = cfid; *ret_cfid = cfid;
atomic_inc(&tcon->num_remote_opens);
}
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment