diff --git a/[refs] b/[refs] index 0ecf054c40b8..2b8910337b7f 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 10fe12ef631a7e85022ed26304a37f033a6a95b8 +refs/heads/master: faa5c5c36ec50bf43e39c7798ce9701e6b002db3 diff --git a/trunk/tools/perf/util/thread.c b/trunk/tools/perf/util/thread.c index 634b7f7140d5..9e8995eaf2b6 100644 --- a/trunk/tools/perf/util/thread.c +++ b/trunk/tools/perf/util/thread.c @@ -36,7 +36,10 @@ int thread__set_comm(struct thread *self, const char *comm) if (self->comm) free(self->comm); self->comm = strdup(comm); - return self->comm ? 0 : -ENOMEM; + if (self->comm == NULL) + return -ENOMEM; + self->comm_set = true; + return 0; } int thread__comm_len(struct thread *self) @@ -255,11 +258,14 @@ int thread__fork(struct thread *self, struct thread *parent) { int i; - if (self->comm) - free(self->comm); - self->comm = strdup(parent->comm); - if (!self->comm) - return -ENOMEM; + if (parent->comm_set) { + if (self->comm) + free(self->comm); + self->comm = strdup(parent->comm); + if (!self->comm) + return -ENOMEM; + self->comm_set = true; + } for (i = 0; i < MAP__NR_TYPES; ++i) if (map_groups__clone(&self->mg, &parent->mg, i) < 0) diff --git a/trunk/tools/perf/util/thread.h b/trunk/tools/perf/util/thread.h index 56f317b8a06c..0a28f39de545 100644 --- a/trunk/tools/perf/util/thread.h +++ b/trunk/tools/perf/util/thread.h @@ -15,6 +15,7 @@ struct thread { struct map_groups mg; pid_t pid; char shortname[3]; + bool comm_set; char *comm; int comm_len; };