Skip to content

Commit 74ebd02

Browse files
sprasad-microsoftsmfrench
authored andcommitted
cifs: all initializations for tcon should happen in tcon_info_alloc
Today, a few work structs inside tcon are initialized inside cifs_get_tcon and not in tcon_info_alloc. As a result, if a tcon is obtained from tcon_info_alloc, but not called as a part of cifs_get_tcon, we may trip over. Cc: <[email protected]> Signed-off-by: Shyam Prasad N <[email protected]> Reviewed-by: Paulo Alcantara (Red Hat) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 3bbe467 commit 74ebd02

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

fs/smb/client/cifsproto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ extern int SendReceiveBlockingLock(const unsigned int xid,
136136
struct smb_hdr *out_buf,
137137
int *bytes_returned);
138138

139+
void smb2_query_server_interfaces(struct work_struct *work);
139140
void
140141
cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server,
141142
bool all_channels);

fs/smb/client/connect.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server)
9797
return rc;
9898
}
9999

100-
static void smb2_query_server_interfaces(struct work_struct *work)
100+
void smb2_query_server_interfaces(struct work_struct *work)
101101
{
102102
int rc;
103103
int xid;
@@ -2880,20 +2880,14 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
28802880
tcon->max_cached_dirs = ctx->max_cached_dirs;
28812881
tcon->nodelete = ctx->nodelete;
28822882
tcon->local_lease = ctx->local_lease;
2883-
INIT_LIST_HEAD(&tcon->pending_opens);
28842883
tcon->status = TID_GOOD;
28852884

2886-
INIT_DELAYED_WORK(&tcon->query_interfaces,
2887-
smb2_query_server_interfaces);
28882885
if (ses->server->dialect >= SMB30_PROT_ID &&
28892886
(ses->server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) {
28902887
/* schedule query interfaces poll */
28912888
queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
28922889
(SMB_INTERFACE_POLL_INTERVAL * HZ));
28932890
}
2894-
#ifdef CONFIG_CIFS_DFS_UPCALL
2895-
INIT_DELAYED_WORK(&tcon->dfs_cache_work, dfs_cache_refresh);
2896-
#endif
28972891
spin_lock(&cifs_tcp_ses_lock);
28982892
list_add(&tcon->tcon_list, &ses->tcon_list);
28992893
spin_unlock(&cifs_tcp_ses_lock);

fs/smb/client/misc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ tcon_info_alloc(bool dir_leases_enabled, enum smb3_tcon_ref_trace trace)
151151
#ifdef CONFIG_CIFS_DFS_UPCALL
152152
INIT_LIST_HEAD(&ret_buf->dfs_ses_list);
153153
#endif
154+
INIT_LIST_HEAD(&ret_buf->pending_opens);
155+
INIT_DELAYED_WORK(&ret_buf->query_interfaces,
156+
smb2_query_server_interfaces);
157+
#ifdef CONFIG_CIFS_DFS_UPCALL
158+
INIT_DELAYED_WORK(&ret_buf->dfs_cache_work, dfs_cache_refresh);
159+
#endif
154160

155161
return ret_buf;
156162
}

0 commit comments

Comments
 (0)