Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cifs: handle empty list of targets in cifs_reconnect()

In case there were no cached DFS referrals in
reconn_setup_dfs_targets(), set cifs_sb to NULL prior to calling
reconn_set_next_dfs_target() so it would not try to access an empty
tgt_list.

Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Paulo Alcantara and committed by
Steve French
a5293035 7d397a03

+6 -4
+6 -4
fs/cifs/connect.c
··· 470 470 sb = NULL; 471 471 } else { 472 472 cifs_sb = CIFS_SB(sb); 473 - 474 473 rc = reconn_setup_dfs_targets(cifs_sb, &tgt_list); 475 - if (rc && (rc != -EOPNOTSUPP)) { 476 - cifs_server_dbg(VFS, "%s: no target servers for DFS failover\n", 477 - __func__); 474 + if (rc) { 475 + cifs_sb = NULL; 476 + if (rc != -EOPNOTSUPP) { 477 + cifs_server_dbg(VFS, "%s: no target servers for DFS failover\n", 478 + __func__); 479 + } 478 480 } else { 479 481 server->nr_targets = dfs_cache_get_nr_tgts(&tgt_list); 480 482 }