X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=lttng-sessiond%2Ftrace-ust.c;h=3916c1f5de97c8dc46fdb650b2f91edd6d971bbe;hp=3e1055a8ba8e990556ebd41b1a1f7748a6ff08d9;hb=3a009adbd8bf5305668e7e41e5e9f12813d04959;hpb=d41f73b7cb50d57974bd1fad22342abaf9718566 diff --git a/lttng-sessiond/trace-ust.c b/lttng-sessiond/trace-ust.c index 3e1055a8b..3916c1f5d 100644 --- a/lttng-sessiond/trace-ust.c +++ b/lttng-sessiond/trace-ust.c @@ -92,13 +92,14 @@ struct ltt_ust_session *trace_ust_create_session(char *path, unsigned int uid, /* Allocate a new ltt ust session */ lus = malloc(sizeof(struct ltt_ust_session)); if (lus == NULL) { - perror("create ust session malloc"); + PERROR("create ust session malloc"); goto error; } /* Init data structure */ lus->consumer_fds_sent = 0; lus->uid = uid; + lus->start_trace = 0; /* Alloc UST domain hash tables */ lus->domain_pid = hashtable_new(0); @@ -111,13 +112,15 @@ struct ltt_ust_session *trace_ust_create_session(char *path, unsigned int uid, ret = snprintf(lus->pathname, PATH_MAX, "%s/ust", path); if (ret < 0) { PERROR("snprintf kernel traces path"); - goto error; + goto error_free_session; } DBG2("UST trace session create successful"); return lus; +error_free_session: + free(lus); error: return NULL; } @@ -168,13 +171,15 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, ret = snprintf(luc->pathname, PATH_MAX, "%s", path); if (ret < 0) { perror("asprintf ust create channel"); - goto error; + goto error_free_channel; } DBG2("Trace UST channel %s created", luc->name); return luc; +error_free_channel: + free(luc); error: return NULL; } @@ -209,7 +214,7 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) break; default: ERR("Unknown ust instrumentation type (%d)", ev->type); - goto error; + goto error_free_event; } /* Copy event name */ @@ -220,10 +225,12 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) hashtable_node_init(&lue->node, (void *) lue->attr.name, strlen(lue->attr.name)); /* Alloc context hash tables */ - lue->ctx = hashtable_new_str(5); + lue->ctx = hashtable_new_str(0); return lue; +error_free_event: + free(lue); error: return NULL; } @@ -238,7 +245,7 @@ struct ltt_ust_metadata *trace_ust_create_metadata(char *path) int ret; struct ltt_ust_metadata *lum; - lum = malloc(sizeof(struct ltt_ust_metadata)); + lum = zmalloc(sizeof(struct ltt_ust_metadata)); if (lum == NULL) { perror("ust metadata malloc"); goto error; @@ -257,11 +264,13 @@ struct ltt_ust_metadata *trace_ust_create_metadata(char *path) ret = snprintf(lum->pathname, PATH_MAX, "%s/metadata", path); if (ret < 0) { perror("asprintf ust metadata"); - goto error; + goto error_free_metadata; } return lum; +error_free_metadata: + free(lum); error: return NULL; }