提交 053569cc 编写于 作者: R Ronnie Sahlberg 提交者: Steve French

cifs: set rc to -ENOENT if we can not get a dentry for the cached dir

We already set rc to this return code further down in the function but
we can set it earlier in order to suppress a smash warning.

Also fix a false positive for Coverity. The reason this is a false positive is
that this happens during umount after all files and directories have been closed
but mosetting on ->on_list to suppress the warning.
Reported-by: NDan carpenter <dan.carpenter@oracle.com>
Reported-by: Ncoverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1525256 ("Concurrent data access violations")
Fixes: a350d6e73f5e ("cifs: enable caching of directories for which a lease is held")
Signed-off-by: NRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: NSteve French <stfrench@microsoft.com>
上级 d32f211a
...@@ -253,9 +253,11 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, ...@@ -253,9 +253,11 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
dentry = dget(cifs_sb->root); dentry = dget(cifs_sb->root);
else { else {
dentry = path_to_dentry(cifs_sb, path); dentry = path_to_dentry(cifs_sb, path);
if (IS_ERR(dentry)) if (IS_ERR(dentry)) {
rc = -ENOENT;
goto oshr_free; goto oshr_free;
} }
}
cfid->dentry = dentry; cfid->dentry = dentry;
cfid->tcon = tcon; cfid->tcon = tcon;
cfid->time = jiffies; cfid->time = jiffies;
...@@ -385,13 +387,13 @@ void invalidate_all_cached_dirs(struct cifs_tcon *tcon) ...@@ -385,13 +387,13 @@ void invalidate_all_cached_dirs(struct cifs_tcon *tcon)
list_move(&cfid->entry, &entry); list_move(&cfid->entry, &entry);
cfids->num_entries--; cfids->num_entries--;
cfid->is_open = false; cfid->is_open = false;
cfid->on_list = false;
/* To prevent race with smb2_cached_lease_break() */ /* To prevent race with smb2_cached_lease_break() */
kref_get(&cfid->refcount); kref_get(&cfid->refcount);
} }
spin_unlock(&cfids->cfid_list_lock); spin_unlock(&cfids->cfid_list_lock);
list_for_each_entry_safe(cfid, q, &entry, entry) { list_for_each_entry_safe(cfid, q, &entry, entry) {
cfid->on_list = false;
list_del(&cfid->entry); list_del(&cfid->entry);
cancel_work_sync(&cfid->lease_break); cancel_work_sync(&cfid->lease_break);
if (cfid->has_lease) { if (cfid->has_lease) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册