|
@@ -498,14 +498,21 @@ static struct ib_srp_root_path_parser ib_srp_rp_parser[] = {
|
498
|
498
|
static int ib_srp_parse_root_path ( const char *rp_string,
|
499
|
499
|
struct ib_srp_root_path *rp ) {
|
500
|
500
|
struct ib_srp_root_path_parser *parser;
|
501
|
|
- char rp_string_copy[ strlen ( rp_string ) + 1 ];
|
502
|
501
|
char *rp_comp[IB_SRP_NUM_RP_COMPONENTS];
|
503
|
|
- char *rp_string_tmp = rp_string_copy;
|
|
502
|
+ char *rp_string_copy;
|
|
503
|
+ char *rp_string_tmp;
|
504
|
504
|
unsigned int i = 0;
|
505
|
505
|
int rc;
|
506
|
506
|
|
|
507
|
+ /* Create modifiable copy of root path */
|
|
508
|
+ rp_string_copy = strdup ( rp_string );
|
|
509
|
+ if ( ! rp_string_copy ) {
|
|
510
|
+ rc = -ENOMEM;
|
|
511
|
+ goto err_strdup;
|
|
512
|
+ }
|
|
513
|
+ rp_string_tmp = rp_string_copy;
|
|
514
|
+
|
507
|
515
|
/* Split root path into component parts */
|
508
|
|
- strcpy ( rp_string_copy, rp_string );
|
509
|
516
|
while ( 1 ) {
|
510
|
517
|
rp_comp[i++] = rp_string_tmp;
|
511
|
518
|
if ( i == IB_SRP_NUM_RP_COMPONENTS )
|
|
@@ -514,7 +521,8 @@ static int ib_srp_parse_root_path ( const char *rp_string,
|
514
|
521
|
if ( ! *rp_string_tmp ) {
|
515
|
522
|
DBG ( "IBSRP root path \"%s\" too short\n",
|
516
|
523
|
rp_string );
|
517
|
|
- return -EINVAL_RP_TOO_SHORT;
|
|
524
|
+ rc = -EINVAL_RP_TOO_SHORT;
|
|
525
|
+ goto err_split;
|
518
|
526
|
}
|
519
|
527
|
}
|
520
|
528
|
*(rp_string_tmp++) = '\0';
|
|
@@ -527,11 +535,15 @@ static int ib_srp_parse_root_path ( const char *rp_string,
|
527
|
535
|
DBG ( "IBSRP could not parse \"%s\" in root path "
|
528
|
536
|
"\"%s\": %s\n", rp_comp[i], rp_string,
|
529
|
537
|
strerror ( rc ) );
|
530
|
|
- return rc;
|
|
538
|
+ goto err_parse;
|
531
|
539
|
}
|
532
|
540
|
}
|
533
|
541
|
|
534
|
|
- return 0;
|
|
542
|
+ err_parse:
|
|
543
|
+ err_split:
|
|
544
|
+ free ( rp_string_copy );
|
|
545
|
+ err_strdup:
|
|
546
|
+ return rc;
|
535
|
547
|
}
|
536
|
548
|
|
537
|
549
|
/**
|