diff options
-rw-r--r-- | tools/perf/util/probe-event.c | 159 | ||||
-rw-r--r-- | tools/perf/util/probe-finder.c | 58 |
2 files changed, 156 insertions, 61 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index aacbf730b475..ca108b2cd15f 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -133,7 +133,9 @@ static int convert_to_perf_probe_point(struct kprobe_trace_point *tp, | |||
133 | if (ret <= 0) { | 133 | if (ret <= 0) { |
134 | pr_debug("Failed to find corresponding probes from " | 134 | pr_debug("Failed to find corresponding probes from " |
135 | "debuginfo. Use kprobe event information.\n"); | 135 | "debuginfo. Use kprobe event information.\n"); |
136 | pp->function = xstrdup(tp->symbol); | 136 | pp->function = strdup(tp->symbol); |
137 | if (pp->function == NULL) | ||
138 | return -ENOMEM; | ||
137 | pp->offset = tp->offset; | 139 | pp->offset = tp->offset; |
138 | } | 140 | } |
139 | pp->retprobe = tp->retprobe; | 141 | pp->retprobe = tp->retprobe; |
@@ -300,7 +302,9 @@ end: | |||
300 | static int convert_to_perf_probe_point(struct kprobe_trace_point *tp, | 302 | static int convert_to_perf_probe_point(struct kprobe_trace_point *tp, |
301 | struct perf_probe_point *pp) | 303 | struct perf_probe_point *pp) |
302 | { | 304 | { |
303 | pp->function = xstrdup(tp->symbol); | 305 | pp->function = strdup(tp->symbol); |
306 | if (pp->function == NULL) | ||
307 | return -ENOMEM; | ||
304 | pp->offset = tp->offset; | 308 | pp->offset = tp->offset; |
305 | pp->retprobe = tp->retprobe; | 309 | pp->retprobe = tp->retprobe; |
306 | 310 | ||
@@ -355,9 +359,12 @@ int parse_line_range_desc(const char *arg, struct line_range *lr) | |||
355 | *tmp); | 359 | *tmp); |
356 | return -EINVAL; | 360 | return -EINVAL; |
357 | } | 361 | } |
358 | tmp = xstrndup(arg, (ptr - arg)); | 362 | tmp = strndup(arg, (ptr - arg)); |
359 | } else | 363 | } else |
360 | tmp = xstrdup(arg); | 364 | tmp = strdup(arg); |
365 | |||
366 | if (tmp == NULL) | ||
367 | return -ENOMEM; | ||
361 | 368 | ||
362 | if (strchr(tmp, '.')) | 369 | if (strchr(tmp, '.')) |
363 | lr->file = tmp; | 370 | lr->file = tmp; |
@@ -406,7 +413,9 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev) | |||
406 | "follow C symbol-naming rule.\n", arg); | 413 | "follow C symbol-naming rule.\n", arg); |
407 | return -EINVAL; | 414 | return -EINVAL; |
408 | } | 415 | } |
409 | pev->event = xstrdup(arg); | 416 | pev->event = strdup(arg); |
417 | if (pev->event == NULL) | ||
418 | return -ENOMEM; | ||
410 | pev->group = NULL; | 419 | pev->group = NULL; |
411 | arg = tmp; | 420 | arg = tmp; |
412 | } | 421 | } |
@@ -417,18 +426,24 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev) | |||
417 | *ptr++ = '\0'; | 426 | *ptr++ = '\0'; |
418 | } | 427 | } |
419 | 428 | ||
429 | tmp = strdup(arg); | ||
430 | if (tmp == NULL) | ||
431 | return -ENOMEM; | ||
432 | |||
420 | /* Check arg is function or file and copy it */ | 433 | /* Check arg is function or file and copy it */ |
421 | if (strchr(arg, '.')) /* File */ | 434 | if (strchr(tmp, '.')) /* File */ |
422 | pp->file = xstrdup(arg); | 435 | pp->file = tmp; |
423 | else /* Function */ | 436 | else /* Function */ |
424 | pp->function = xstrdup(arg); | 437 | pp->function = tmp; |
425 | 438 | ||
426 | /* Parse other options */ | 439 | /* Parse other options */ |
427 | while (ptr) { | 440 | while (ptr) { |
428 | arg = ptr; | 441 | arg = ptr; |
429 | c = nc; | 442 | c = nc; |
430 | if (c == ';') { /* Lazy pattern must be the last part */ | 443 | if (c == ';') { /* Lazy pattern must be the last part */ |
431 | pp->lazy_line = xstrdup(arg); | 444 | pp->lazy_line = strdup(arg); |
445 | if (pp->lazy_line == NULL) | ||
446 | return -ENOMEM; | ||
432 | break; | 447 | break; |
433 | } | 448 | } |
434 | ptr = strpbrk(arg, ";:+@%"); | 449 | ptr = strpbrk(arg, ";:+@%"); |
@@ -458,7 +473,9 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev) | |||
458 | semantic_error("SRC@SRC is not allowed.\n"); | 473 | semantic_error("SRC@SRC is not allowed.\n"); |
459 | return -EINVAL; | 474 | return -EINVAL; |
460 | } | 475 | } |
461 | pp->file = xstrdup(arg); | 476 | pp->file = strdup(arg); |
477 | if (pp->file == NULL) | ||
478 | return -ENOMEM; | ||
462 | break; | 479 | break; |
463 | case '%': /* Probe places */ | 480 | case '%': /* Probe places */ |
464 | if (strcmp(arg, "return") == 0) { | 481 | if (strcmp(arg, "return") == 0) { |
@@ -530,7 +547,9 @@ static int parse_perf_probe_arg(char *str, struct perf_probe_arg *arg) | |||
530 | 547 | ||
531 | tmp = strchr(str, '='); | 548 | tmp = strchr(str, '='); |
532 | if (tmp) { | 549 | if (tmp) { |
533 | arg->name = xstrndup(str, tmp - str); | 550 | arg->name = strndup(str, tmp - str); |
551 | if (arg->name == NULL) | ||
552 | return -ENOMEM; | ||
534 | pr_debug("name:%s ", arg->name); | 553 | pr_debug("name:%s ", arg->name); |
535 | str = tmp + 1; | 554 | str = tmp + 1; |
536 | } | 555 | } |
@@ -538,20 +557,26 @@ static int parse_perf_probe_arg(char *str, struct perf_probe_arg *arg) | |||
538 | tmp = strchr(str, ':'); | 557 | tmp = strchr(str, ':'); |
539 | if (tmp) { /* Type setting */ | 558 | if (tmp) { /* Type setting */ |
540 | *tmp = '\0'; | 559 | *tmp = '\0'; |
541 | arg->type = xstrdup(tmp + 1); | 560 | arg->type = strdup(tmp + 1); |
561 | if (arg->type == NULL) | ||
562 | return -ENOMEM; | ||
542 | pr_debug("type:%s ", arg->type); | 563 | pr_debug("type:%s ", arg->type); |
543 | } | 564 | } |
544 | 565 | ||
545 | tmp = strpbrk(str, "-."); | 566 | tmp = strpbrk(str, "-."); |
546 | if (!is_c_varname(str) || !tmp) { | 567 | if (!is_c_varname(str) || !tmp) { |
547 | /* A variable, register, symbol or special value */ | 568 | /* A variable, register, symbol or special value */ |
548 | arg->var = xstrdup(str); | 569 | arg->var = strdup(str); |
570 | if (arg->var == NULL) | ||
571 | return -ENOMEM; | ||
549 | pr_debug("%s\n", arg->var); | 572 | pr_debug("%s\n", arg->var); |
550 | return 0; | 573 | return 0; |
551 | } | 574 | } |
552 | 575 | ||
553 | /* Structure fields */ | 576 | /* Structure fields */ |
554 | arg->var = xstrndup(str, tmp - str); | 577 | arg->var = strndup(str, tmp - str); |
578 | if (arg->var == NULL) | ||
579 | return -ENOMEM; | ||
555 | pr_debug("%s, ", arg->var); | 580 | pr_debug("%s, ", arg->var); |
556 | fieldp = &arg->field; | 581 | fieldp = &arg->field; |
557 | 582 | ||
@@ -572,18 +597,24 @@ static int parse_perf_probe_arg(char *str, struct perf_probe_arg *arg) | |||
572 | 597 | ||
573 | tmp = strpbrk(str, "-."); | 598 | tmp = strpbrk(str, "-."); |
574 | if (tmp) { | 599 | if (tmp) { |
575 | (*fieldp)->name = xstrndup(str, tmp - str); | 600 | (*fieldp)->name = strndup(str, tmp - str); |
601 | if ((*fieldp)->name == NULL) | ||
602 | return -ENOMEM; | ||
576 | pr_debug("%s(%d), ", (*fieldp)->name, (*fieldp)->ref); | 603 | pr_debug("%s(%d), ", (*fieldp)->name, (*fieldp)->ref); |
577 | fieldp = &(*fieldp)->next; | 604 | fieldp = &(*fieldp)->next; |
578 | } | 605 | } |
579 | } while (tmp); | 606 | } while (tmp); |
580 | (*fieldp)->name = xstrdup(str); | 607 | (*fieldp)->name = strdup(str); |
608 | if ((*fieldp)->name == NULL) | ||
609 | return -ENOMEM; | ||
581 | pr_debug("%s(%d)\n", (*fieldp)->name, (*fieldp)->ref); | 610 | pr_debug("%s(%d)\n", (*fieldp)->name, (*fieldp)->ref); |
582 | 611 | ||
583 | /* If no name is specified, set the last field name */ | 612 | /* If no name is specified, set the last field name */ |
584 | if (!arg->name) | 613 | if (!arg->name) { |
585 | arg->name = xstrdup((*fieldp)->name); | 614 | arg->name = strdup((*fieldp)->name); |
586 | 615 | if (arg->name == NULL) | |
616 | return -ENOMEM; | ||
617 | } | ||
587 | return 0; | 618 | return 0; |
588 | } | 619 | } |
589 | 620 | ||
@@ -697,9 +728,13 @@ int parse_kprobe_trace_command(const char *cmd, struct kprobe_trace_event *tev) | |||
697 | *p++ = '\0'; | 728 | *p++ = '\0'; |
698 | else | 729 | else |
699 | p = argv[i + 2]; | 730 | p = argv[i + 2]; |
700 | tev->args[i].name = xstrdup(argv[i + 2]); | 731 | tev->args[i].name = strdup(argv[i + 2]); |
701 | /* TODO: parse regs and offset */ | 732 | /* TODO: parse regs and offset */ |
702 | tev->args[i].value = xstrdup(p); | 733 | tev->args[i].value = strdup(p); |
734 | if (tev->args[i].name == NULL || tev->args[i].value == NULL) { | ||
735 | ret = -ENOMEM; | ||
736 | goto out; | ||
737 | } | ||
703 | } | 738 | } |
704 | ret = 0; | 739 | ret = 0; |
705 | out: | 740 | out: |
@@ -933,12 +968,14 @@ error: | |||
933 | int convert_to_perf_probe_event(struct kprobe_trace_event *tev, | 968 | int convert_to_perf_probe_event(struct kprobe_trace_event *tev, |
934 | struct perf_probe_event *pev) | 969 | struct perf_probe_event *pev) |
935 | { | 970 | { |
936 | char buf[64]; | 971 | char buf[64] = ""; |
937 | int i, ret; | 972 | int i, ret; |
938 | 973 | ||
939 | /* Convert event/group name */ | 974 | /* Convert event/group name */ |
940 | pev->event = xstrdup(tev->event); | 975 | pev->event = strdup(tev->event); |
941 | pev->group = xstrdup(tev->group); | 976 | pev->group = strdup(tev->group); |
977 | if (pev->event == NULL || pev->group == NULL) | ||
978 | return -ENOMEM; | ||
942 | 979 | ||
943 | /* Convert trace_point to probe_point */ | 980 | /* Convert trace_point to probe_point */ |
944 | ret = convert_to_perf_probe_point(&tev->point, &pev->point); | 981 | ret = convert_to_perf_probe_point(&tev->point, &pev->point); |
@@ -950,14 +987,17 @@ int convert_to_perf_probe_event(struct kprobe_trace_event *tev, | |||
950 | pev->args = zalloc(sizeof(struct perf_probe_arg) * pev->nargs); | 987 | pev->args = zalloc(sizeof(struct perf_probe_arg) * pev->nargs); |
951 | if (pev->args == NULL) | 988 | if (pev->args == NULL) |
952 | return -ENOMEM; | 989 | return -ENOMEM; |
953 | for (i = 0; i < tev->nargs && ret >= 0; i++) | 990 | for (i = 0; i < tev->nargs && ret >= 0; i++) { |
954 | if (tev->args[i].name) | 991 | if (tev->args[i].name) |
955 | pev->args[i].name = xstrdup(tev->args[i].name); | 992 | pev->args[i].name = strdup(tev->args[i].name); |
956 | else { | 993 | else { |
957 | ret = synthesize_kprobe_trace_arg(&tev->args[i], | 994 | ret = synthesize_kprobe_trace_arg(&tev->args[i], |
958 | buf, 64); | 995 | buf, 64); |
959 | pev->args[i].name = xstrdup(buf); | 996 | pev->args[i].name = strdup(buf); |
960 | } | 997 | } |
998 | if (pev->args[i].name == NULL && ret >= 0) | ||
999 | ret = -ENOMEM; | ||
1000 | } | ||
961 | 1001 | ||
962 | if (ret < 0) | 1002 | if (ret < 0) |
963 | clear_perf_probe_event(pev); | 1003 | clear_perf_probe_event(pev); |
@@ -1282,7 +1322,7 @@ static int __add_kprobe_trace_events(struct perf_probe_event *pev, | |||
1282 | 1322 | ||
1283 | ret = 0; | 1323 | ret = 0; |
1284 | printf("Add new event%s\n", (ntevs > 1) ? "s:" : ":"); | 1324 | printf("Add new event%s\n", (ntevs > 1) ? "s:" : ":"); |
1285 | for (i = 0; i < ntevs && ret >= 0; i++) { | 1325 | for (i = 0; i < ntevs; i++) { |
1286 | tev = &tevs[i]; | 1326 | tev = &tevs[i]; |
1287 | if (pev->event) | 1327 | if (pev->event) |
1288 | event = pev->event; | 1328 | event = pev->event; |
@@ -1303,8 +1343,12 @@ static int __add_kprobe_trace_events(struct perf_probe_event *pev, | |||
1303 | break; | 1343 | break; |
1304 | event = buf; | 1344 | event = buf; |
1305 | 1345 | ||
1306 | tev->event = xstrdup(event); | 1346 | tev->event = strdup(event); |
1307 | tev->group = xstrdup(group); | 1347 | tev->group = strdup(group); |
1348 | if (tev->event == NULL || tev->group == NULL) { | ||
1349 | ret = -ENOMEM; | ||
1350 | break; | ||
1351 | } | ||
1308 | ret = write_kprobe_trace_event(fd, tev); | 1352 | ret = write_kprobe_trace_event(fd, tev); |
1309 | if (ret < 0) | 1353 | if (ret < 0) |
1310 | break; | 1354 | break; |
@@ -1360,23 +1404,40 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev, | |||
1360 | return -ENOMEM; | 1404 | return -ENOMEM; |
1361 | 1405 | ||
1362 | /* Copy parameters */ | 1406 | /* Copy parameters */ |
1363 | tev->point.symbol = xstrdup(pev->point.function); | 1407 | tev->point.symbol = strdup(pev->point.function); |
1408 | if (tev->point.symbol == NULL) { | ||
1409 | ret = -ENOMEM; | ||
1410 | goto error; | ||
1411 | } | ||
1364 | tev->point.offset = pev->point.offset; | 1412 | tev->point.offset = pev->point.offset; |
1365 | tev->nargs = pev->nargs; | 1413 | tev->nargs = pev->nargs; |
1366 | if (tev->nargs) { | 1414 | if (tev->nargs) { |
1367 | tev->args = zalloc(sizeof(struct kprobe_trace_arg) | 1415 | tev->args = zalloc(sizeof(struct kprobe_trace_arg) |
1368 | * tev->nargs); | 1416 | * tev->nargs); |
1369 | if (tev->args == NULL) { | 1417 | if (tev->args == NULL) { |
1370 | free(tev); | 1418 | ret = -ENOMEM; |
1371 | *tevs = NULL; | 1419 | goto error; |
1372 | return -ENOMEM; | ||
1373 | } | 1420 | } |
1374 | for (i = 0; i < tev->nargs; i++) { | 1421 | for (i = 0; i < tev->nargs; i++) { |
1375 | if (pev->args[i].name) | 1422 | if (pev->args[i].name) { |
1376 | tev->args[i].name = xstrdup(pev->args[i].name); | 1423 | tev->args[i].name = strdup(pev->args[i].name); |
1377 | tev->args[i].value = xstrdup(pev->args[i].var); | 1424 | if (tev->args[i].name == NULL) { |
1378 | if (pev->args[i].type) | 1425 | ret = -ENOMEM; |
1379 | tev->args[i].type = xstrdup(pev->args[i].type); | 1426 | goto error; |
1427 | } | ||
1428 | } | ||
1429 | tev->args[i].value = strdup(pev->args[i].var); | ||
1430 | if (tev->args[i].value == NULL) { | ||
1431 | ret = -ENOMEM; | ||
1432 | goto error; | ||
1433 | } | ||
1434 | if (pev->args[i].type) { | ||
1435 | tev->args[i].type = strdup(pev->args[i].type); | ||
1436 | if (tev->args[i].type == NULL) { | ||
1437 | ret = -ENOMEM; | ||
1438 | goto error; | ||
1439 | } | ||
1440 | } | ||
1380 | } | 1441 | } |
1381 | } | 1442 | } |
1382 | 1443 | ||
@@ -1386,13 +1447,15 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev, | |||
1386 | if (!sym) { | 1447 | if (!sym) { |
1387 | pr_warning("Kernel symbol \'%s\' not found.\n", | 1448 | pr_warning("Kernel symbol \'%s\' not found.\n", |
1388 | tev->point.symbol); | 1449 | tev->point.symbol); |
1389 | clear_kprobe_trace_event(tev); | 1450 | ret = -ENOENT; |
1390 | free(tev); | 1451 | goto error; |
1391 | *tevs = NULL; | 1452 | } |
1392 | return -ENOENT; | ||
1393 | } else | ||
1394 | ret = 1; | ||
1395 | 1453 | ||
1454 | return 1; | ||
1455 | error: | ||
1456 | clear_kprobe_trace_event(tev); | ||
1457 | free(tev); | ||
1458 | *tevs = NULL; | ||
1396 | return ret; | 1459 | return ret; |
1397 | } | 1460 | } |
1398 | 1461 | ||
@@ -1528,7 +1591,11 @@ int del_perf_probe_events(struct strlist *dellist) | |||
1528 | return -EINVAL; | 1591 | return -EINVAL; |
1529 | 1592 | ||
1530 | strlist__for_each(ent, dellist) { | 1593 | strlist__for_each(ent, dellist) { |
1531 | str = xstrdup(ent->s); | 1594 | str = strdup(ent->s); |
1595 | if (str == NULL) { | ||
1596 | ret = -ENOMEM; | ||
1597 | break; | ||
1598 | } | ||
1532 | pr_debug("Parsing: %s\n", str); | 1599 | pr_debug("Parsing: %s\n", str); |
1533 | p = strchr(str, ':'); | 1600 | p = strchr(str, ':'); |
1534 | if (p) { | 1601 | if (p) { |
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index ce1ac827f3d2..e443e69a4d2e 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -424,7 +424,10 @@ static int convert_location(Dwarf_Op *op, struct probe_finder *pf) | |||
424 | return -ERANGE; | 424 | return -ERANGE; |
425 | } | 425 | } |
426 | 426 | ||
427 | tvar->value = xstrdup(regs); | 427 | tvar->value = strdup(regs); |
428 | if (tvar->value == NULL) | ||
429 | return -ENOMEM; | ||
430 | |||
428 | if (ref) { | 431 | if (ref) { |
429 | tvar->ref = zalloc(sizeof(struct kprobe_trace_arg_ref)); | 432 | tvar->ref = zalloc(sizeof(struct kprobe_trace_arg_ref)); |
430 | if (tvar->ref == NULL) | 433 | if (tvar->ref == NULL) |
@@ -466,7 +469,9 @@ static int convert_variable_type(Dwarf_Die *vr_die, | |||
466 | strerror(-ret)); | 469 | strerror(-ret)); |
467 | return ret; | 470 | return ret; |
468 | } | 471 | } |
469 | targ->type = xstrdup(buf); | 472 | targ->type = strdup(buf); |
473 | if (targ->type == NULL) | ||
474 | return -ENOMEM; | ||
470 | } | 475 | } |
471 | return 0; | 476 | return 0; |
472 | } | 477 | } |
@@ -576,9 +581,11 @@ static int convert_variable(Dwarf_Die *vr_die, struct probe_finder *pf) | |||
576 | vr_die = &die_mem; | 581 | vr_die = &die_mem; |
577 | } | 582 | } |
578 | if (ret == 0) { | 583 | if (ret == 0) { |
579 | if (pf->pvar->type) | 584 | if (pf->pvar->type) { |
580 | pf->tvar->type = xstrdup(pf->pvar->type); | 585 | pf->tvar->type = strdup(pf->pvar->type); |
581 | else | 586 | if (pf->tvar->type == NULL) |
587 | ret = -ENOMEM; | ||
588 | } else | ||
582 | ret = convert_variable_type(vr_die, pf->tvar); | 589 | ret = convert_variable_type(vr_die, pf->tvar); |
583 | } | 590 | } |
584 | /* *expr will be cached in libdw. Don't free it. */ | 591 | /* *expr will be cached in libdw. Don't free it. */ |
@@ -595,22 +602,30 @@ static int find_variable(Dwarf_Die *sp_die, struct probe_finder *pf) | |||
595 | { | 602 | { |
596 | Dwarf_Die vr_die; | 603 | Dwarf_Die vr_die; |
597 | char buf[32], *ptr; | 604 | char buf[32], *ptr; |
605 | int ret; | ||
598 | 606 | ||
599 | /* TODO: Support arrays */ | 607 | /* TODO: Support arrays */ |
600 | if (pf->pvar->name) | 608 | if (pf->pvar->name) |
601 | pf->tvar->name = xstrdup(pf->pvar->name); | 609 | pf->tvar->name = strdup(pf->pvar->name); |
602 | else { | 610 | else { |
603 | synthesize_perf_probe_arg(pf->pvar, buf, 32); | 611 | ret = synthesize_perf_probe_arg(pf->pvar, buf, 32); |
612 | if (ret < 0) | ||
613 | return ret; | ||
604 | ptr = strchr(buf, ':'); /* Change type separator to _ */ | 614 | ptr = strchr(buf, ':'); /* Change type separator to _ */ |
605 | if (ptr) | 615 | if (ptr) |
606 | *ptr = '_'; | 616 | *ptr = '_'; |
607 | pf->tvar->name = xstrdup(buf); | 617 | pf->tvar->name = strdup(buf); |
608 | } | 618 | } |
619 | if (pf->tvar->name == NULL) | ||
620 | return -ENOMEM; | ||
609 | 621 | ||
610 | if (!is_c_varname(pf->pvar->var)) { | 622 | if (!is_c_varname(pf->pvar->var)) { |
611 | /* Copy raw parameters */ | 623 | /* Copy raw parameters */ |
612 | pf->tvar->value = xstrdup(pf->pvar->var); | 624 | pf->tvar->value = strdup(pf->pvar->var); |
613 | return 0; | 625 | if (pf->tvar->value == NULL) |
626 | return -ENOMEM; | ||
627 | else | ||
628 | return 0; | ||
614 | } | 629 | } |
615 | 630 | ||
616 | pr_debug("Searching '%s' variable in context.\n", | 631 | pr_debug("Searching '%s' variable in context.\n", |
@@ -660,7 +675,9 @@ static int convert_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf) | |||
660 | dwarf_diename(sp_die)); | 675 | dwarf_diename(sp_die)); |
661 | return -ENOENT; | 676 | return -ENOENT; |
662 | } | 677 | } |
663 | tev->point.symbol = xstrdup(name); | 678 | tev->point.symbol = strdup(name); |
679 | if (tev->point.symbol == NULL) | ||
680 | return -ENOMEM; | ||
664 | tev->point.offset = (unsigned long)(pf->addr - eaddr); | 681 | tev->point.offset = (unsigned long)(pf->addr - eaddr); |
665 | } else | 682 | } else |
666 | /* This function has no name. */ | 683 | /* This function has no name. */ |
@@ -1028,7 +1045,11 @@ int find_perf_probe_point(int fd, unsigned long addr, | |||
1028 | tmp = dwarf_linesrc(line, NULL, NULL); | 1045 | tmp = dwarf_linesrc(line, NULL, NULL); |
1029 | if (tmp) { | 1046 | if (tmp) { |
1030 | ppt->line = lineno; | 1047 | ppt->line = lineno; |
1031 | ppt->file = xstrdup(tmp); | 1048 | ppt->file = strdup(tmp); |
1049 | if (ppt->file == NULL) { | ||
1050 | ret = -ENOMEM; | ||
1051 | goto end; | ||
1052 | } | ||
1032 | found = true; | 1053 | found = true; |
1033 | } | 1054 | } |
1034 | } | 1055 | } |
@@ -1064,7 +1085,11 @@ int find_perf_probe_point(int fd, unsigned long addr, | |||
1064 | /* We don't have a line number, let's use offset */ | 1085 | /* We don't have a line number, let's use offset */ |
1065 | ppt->offset = addr - (unsigned long)eaddr; | 1086 | ppt->offset = addr - (unsigned long)eaddr; |
1066 | found: | 1087 | found: |
1067 | ppt->function = xstrdup(tmp); | 1088 | ppt->function = strdup(tmp); |
1089 | if (ppt->function == NULL) { | ||
1090 | ret = -ENOMEM; | ||
1091 | goto end; | ||
1092 | } | ||
1068 | found = true; | 1093 | found = true; |
1069 | } | 1094 | } |
1070 | 1095 | ||
@@ -1116,8 +1141,11 @@ static int find_line_range_by_line(Dwarf_Die *sp_die, struct line_finder *lf) | |||
1116 | continue; | 1141 | continue; |
1117 | 1142 | ||
1118 | /* Copy real path */ | 1143 | /* Copy real path */ |
1119 | if (!lf->lr->path) | 1144 | if (!lf->lr->path) { |
1120 | lf->lr->path = xstrdup(src); | 1145 | lf->lr->path = strdup(src); |
1146 | if (lf->lr->path == NULL) | ||
1147 | return -ENOMEM; | ||
1148 | } | ||
1121 | line_list__add_line(&lf->lr->line_list, (unsigned int)lineno); | 1149 | line_list__add_line(&lf->lr->line_list, (unsigned int)lineno); |
1122 | } | 1150 | } |
1123 | /* Update status */ | 1151 | /* Update status */ |