@@ -327,8 +327,8 @@ static int update_server_fullpath(struct TCP_Server_Info *server, struct cifs_sb
327
327
return rc ;
328
328
}
329
329
330
- static int target_share_matches_server (struct TCP_Server_Info * server , const char * tcp_host ,
331
- size_t tcp_host_len , char * share , bool * target_match )
330
+ static int target_share_matches_server (struct TCP_Server_Info * server , char * share ,
331
+ bool * target_match )
332
332
{
333
333
int rc = 0 ;
334
334
const char * dfs_host ;
@@ -338,13 +338,16 @@ static int target_share_matches_server(struct TCP_Server_Info *server, const cha
338
338
extract_unc_hostname (share , & dfs_host , & dfs_host_len );
339
339
340
340
/* Check if hostnames or addresses match */
341
- if (dfs_host_len != tcp_host_len || strncasecmp (dfs_host , tcp_host , dfs_host_len ) != 0 ) {
342
- cifs_dbg (FYI , "%s: %.*s doesn't match %.*s\n" , __func__ , (int )dfs_host_len ,
343
- dfs_host , (int )tcp_host_len , tcp_host );
341
+ cifs_server_lock (server );
342
+ if (dfs_host_len != strlen (server -> hostname ) ||
343
+ strncasecmp (dfs_host , server -> hostname , dfs_host_len )) {
344
+ cifs_dbg (FYI , "%s: %.*s doesn't match %s\n" , __func__ ,
345
+ (int )dfs_host_len , dfs_host , server -> hostname );
344
346
rc = match_target_ip (server , dfs_host , dfs_host_len , target_match );
345
347
if (rc )
346
348
cifs_dbg (VFS , "%s: failed to match target ip: %d\n" , __func__ , rc );
347
349
}
350
+ cifs_server_unlock (server );
348
351
return rc ;
349
352
}
350
353
@@ -358,13 +361,9 @@ static int __tree_connect_dfs_target(const unsigned int xid, struct cifs_tcon *t
358
361
struct cifs_ses * root_ses = CIFS_DFS_ROOT_SES (tcon -> ses );
359
362
struct cifs_tcon * ipc = root_ses -> tcon_ipc ;
360
363
char * share = NULL , * prefix = NULL ;
361
- const char * tcp_host ;
362
- size_t tcp_host_len ;
363
364
struct dfs_cache_tgt_iterator * tit ;
364
365
bool target_match ;
365
366
366
- extract_unc_hostname (server -> hostname , & tcp_host , & tcp_host_len );
367
-
368
367
tit = dfs_cache_get_tgt_iterator (tl );
369
368
if (!tit ) {
370
369
rc = - ENOENT ;
@@ -387,8 +386,7 @@ static int __tree_connect_dfs_target(const unsigned int xid, struct cifs_tcon *t
387
386
break ;
388
387
}
389
388
390
- rc = target_share_matches_server (server , tcp_host , tcp_host_len , share ,
391
- & target_match );
389
+ rc = target_share_matches_server (server , share , & target_match );
392
390
if (rc )
393
391
break ;
394
392
if (!target_match ) {
@@ -497,7 +495,9 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
497
495
}
498
496
499
497
if (tcon -> ipc ) {
498
+ cifs_server_lock (server );
500
499
scnprintf (tree , MAX_TREE_SIZE , "\\\\%s\\IPC$" , server -> hostname );
500
+ cifs_server_unlock (server );
501
501
rc = ops -> tree_connect (xid , tcon -> ses , tree , tcon , nlsc );
502
502
goto out ;
503
503
}
0 commit comments