Skip to content

Commit 6976c7a

Browse files
Wang Zhaolongsmfrench
authored andcommitted
smb: client: Fix NULL pointer dereference in cifs_debug_dirs_proc_show()
Reading /proc/fs/cifs/open_dirs may hit a NULL dereference when tcon->cfids is NULL. Add NULL check before accessing cfids to prevent the crash. Reproduction: - Mount CIFS share - cat /proc/fs/cifs/open_dirs Fixes: 844e5c0 ("smb3 client: add way to show directory leases for improved debugging") Signed-off-by: Wang Zhaolong <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent b320789 commit 6976c7a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/smb/client/cifs_debug.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ static int cifs_debug_dirs_proc_show(struct seq_file *m, void *v)
304304
list_for_each(tmp1, &ses->tcon_list) {
305305
tcon = list_entry(tmp1, struct cifs_tcon, tcon_list);
306306
cfids = tcon->cfids;
307+
if (!cfids)
308+
continue;
307309
spin_lock(&cfids->cfid_list_lock); /* check lock ordering */
308310
seq_printf(m, "Num entries: %d\n", cfids->num_entries);
309311
list_for_each_entry(cfid, &cfids->entries, entry) {
@@ -319,8 +321,6 @@ static int cifs_debug_dirs_proc_show(struct seq_file *m, void *v)
319321
seq_printf(m, "\n");
320322
}
321323
spin_unlock(&cfids->cfid_list_lock);
322-
323-
324324
}
325325
}
326326
}

0 commit comments

Comments
 (0)