@@ -360,11 +360,11 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
360
360
{
361
361
struct TCP_Server_Info * chan_server ;
362
362
struct cifs_chan * chan ;
363
- struct smb3_fs_context ctx = { NULL } ;
363
+ struct smb3_fs_context * ctx ;
364
364
static const char unc_fmt [] = "\\%s\\foo" ;
365
- char unc [sizeof (unc_fmt )+ SERVER_NAME_LEN_WITH_NULL ] = {0 };
366
365
struct sockaddr_in * ipv4 = (struct sockaddr_in * )& iface -> sockaddr ;
367
366
struct sockaddr_in6 * ipv6 = (struct sockaddr_in6 * )& iface -> sockaddr ;
367
+ size_t len ;
368
368
int rc ;
369
369
unsigned int xid = get_xid ();
370
370
@@ -388,54 +388,64 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
388
388
* the session and server without caring about memory
389
389
* management.
390
390
*/
391
+ ctx = kzalloc (sizeof (* ctx ), GFP_KERNEL );
392
+ if (!ctx ) {
393
+ rc = - ENOMEM ;
394
+ goto out_free_xid ;
395
+ }
391
396
392
397
/* Always make new connection for now (TODO?) */
393
- ctx . nosharesock = true;
398
+ ctx -> nosharesock = true;
394
399
395
400
/* Auth */
396
- ctx . domainauto = ses -> domainAuto ;
397
- ctx . domainname = ses -> domainName ;
401
+ ctx -> domainauto = ses -> domainAuto ;
402
+ ctx -> domainname = ses -> domainName ;
398
403
399
404
/* no hostname for extra channels */
400
- ctx . server_hostname = "" ;
405
+ ctx -> server_hostname = "" ;
401
406
402
- ctx . username = ses -> user_name ;
403
- ctx . password = ses -> password ;
404
- ctx . sectype = ses -> sectype ;
405
- ctx . sign = ses -> sign ;
407
+ ctx -> username = ses -> user_name ;
408
+ ctx -> password = ses -> password ;
409
+ ctx -> sectype = ses -> sectype ;
410
+ ctx -> sign = ses -> sign ;
406
411
407
412
/* UNC and paths */
408
413
/* XXX: Use ses->server->hostname? */
409
- sprintf (unc , unc_fmt , ses -> ip_addr );
410
- ctx .UNC = unc ;
411
- ctx .prepath = "" ;
414
+ len = sizeof (unc_fmt ) + SERVER_NAME_LEN_WITH_NULL ;
415
+ ctx -> UNC = kzalloc (len , GFP_KERNEL );
416
+ if (!ctx -> UNC ) {
417
+ rc = - ENOMEM ;
418
+ goto out_free_ctx ;
419
+ }
420
+ scnprintf (ctx -> UNC , len , unc_fmt , ses -> ip_addr );
421
+ ctx -> prepath = "" ;
412
422
413
423
/* Reuse same version as master connection */
414
- ctx . vals = ses -> server -> vals ;
415
- ctx . ops = ses -> server -> ops ;
424
+ ctx -> vals = ses -> server -> vals ;
425
+ ctx -> ops = ses -> server -> ops ;
416
426
417
- ctx . noblocksnd = ses -> server -> noblocksnd ;
418
- ctx . noautotune = ses -> server -> noautotune ;
419
- ctx . sockopt_tcp_nodelay = ses -> server -> tcp_nodelay ;
420
- ctx . echo_interval = ses -> server -> echo_interval / HZ ;
421
- ctx . max_credits = ses -> server -> max_credits ;
427
+ ctx -> noblocksnd = ses -> server -> noblocksnd ;
428
+ ctx -> noautotune = ses -> server -> noautotune ;
429
+ ctx -> sockopt_tcp_nodelay = ses -> server -> tcp_nodelay ;
430
+ ctx -> echo_interval = ses -> server -> echo_interval / HZ ;
431
+ ctx -> max_credits = ses -> server -> max_credits ;
422
432
423
433
/*
424
434
* This will be used for encoding/decoding user/domain/pw
425
435
* during sess setup auth.
426
436
*/
427
- ctx . local_nls = cifs_sb -> local_nls ;
437
+ ctx -> local_nls = cifs_sb -> local_nls ;
428
438
429
439
/* Use RDMA if possible */
430
- ctx . rdma = iface -> rdma_capable ;
431
- memcpy (& ctx . dstaddr , & iface -> sockaddr , sizeof (struct sockaddr_storage ));
440
+ ctx -> rdma = iface -> rdma_capable ;
441
+ memcpy (& ctx -> dstaddr , & iface -> sockaddr , sizeof (ctx -> dstaddr ));
432
442
433
443
/* reuse master con client guid */
434
- memcpy (& ctx . client_guid , ses -> server -> client_guid ,
435
- SMB2_CLIENT_GUID_SIZE );
436
- ctx . use_client_guid = true;
444
+ memcpy (& ctx -> client_guid , ses -> server -> client_guid ,
445
+ sizeof ( ctx -> client_guid ) );
446
+ ctx -> use_client_guid = true;
437
447
438
- chan_server = cifs_get_tcp_session (& ctx , ses -> server );
448
+ chan_server = cifs_get_tcp_session (ctx , ses -> server );
439
449
440
450
spin_lock (& ses -> chan_lock );
441
451
chan = & ses -> chans [ses -> chan_count ];
@@ -497,6 +507,10 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
497
507
cifs_put_tcp_session (chan -> server , 0 );
498
508
}
499
509
510
+ kfree (ctx -> UNC );
511
+ out_free_ctx :
512
+ kfree (ctx );
513
+ out_free_xid :
500
514
free_xid (xid );
501
515
return rc ;
502
516
}
0 commit comments