diff options
author | Wang Zhaolong <wangzhaolong@huaweicloud.com> | 2025-08-29 08:59:59 +0800 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2025-08-31 17:46:57 -0500 |
commit | 6976c7a69dafbb34a0d4814e2def9d3d7114836d (patch) | |
tree | f75ed457abfa4afd783dfb7f4936aa89b4a7748c | |
parent | b320789d6883cc00ac78ce83bccbfe7ed58afcf0 (diff) |
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: 844e5c0eb176 ("smb3 client: add way to show directory leases for improved debugging")
Signed-off-by: Wang Zhaolong <wangzhaolong@huaweicloud.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
-rw-r--r-- | fs/smb/client/cifs_debug.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/smb/client/cifs_debug.c b/fs/smb/client/cifs_debug.c index beb4f18f05ef..edb2e7f7fc23 100644 --- a/fs/smb/client/cifs_debug.c +++ b/fs/smb/client/cifs_debug.c @@ -304,6 +304,8 @@ static int cifs_debug_dirs_proc_show(struct seq_file *m, void *v) list_for_each(tmp1, &ses->tcon_list) { tcon = list_entry(tmp1, struct cifs_tcon, tcon_list); cfids = tcon->cfids; + if (!cfids) + continue; spin_lock(&cfids->cfid_list_lock); /* check lock ordering */ seq_printf(m, "Num entries: %d\n", cfids->num_entries); 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) seq_printf(m, "\n"); } spin_unlock(&cfids->cfid_list_lock); - - } } } |