projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: memory leak in error path in UST registry
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
ust-registry.c
diff --git
a/src/bin/lttng-sessiond/ust-registry.c
b/src/bin/lttng-sessiond/ust-registry.c
index 7250dd12d751b0edcce93ffd4b886f8bdd7c7395..399d48f681d8e0aa22bd269109e580f0e2206d77 100644
(file)
--- a/
src/bin/lttng-sessiond/ust-registry.c
+++ b/
src/bin/lttng-sessiond/ust-registry.c
@@
-320,7
+320,9
@@
void destroy_channel_rcu(struct rcu_head *head)
struct ust_registry_channel *chan =
caa_container_of(head, struct ust_registry_channel, rcu_head);
struct ust_registry_channel *chan =
caa_container_of(head, struct ust_registry_channel, rcu_head);
- lttng_ht_destroy(chan->ht);
+ if (chan->ht) {
+ lttng_ht_destroy(chan->ht);
+ }
free(chan);
}
free(chan);
}
@@
-361,7
+363,7
@@
int ust_registry_channel_add(struct ust_registry_session *session,
if (!chan) {
PERROR("zmalloc ust registry channel");
ret = -ENOMEM;
if (!chan) {
PERROR("zmalloc ust registry channel");
ret = -ENOMEM;
- goto error;
+ goto error
_alloc
;
}
chan->ht = lttng_ht_new(0, LTTNG_HT_TYPE_STRING);
}
chan->ht = lttng_ht_new(0, LTTNG_HT_TYPE_STRING);
@@
-390,7
+392,11
@@
int ust_registry_channel_add(struct ust_registry_session *session,
lttng_ht_add_unique_u64(session->channels, &chan->node);
rcu_read_unlock();
lttng_ht_add_unique_u64(session->channels, &chan->node);
rcu_read_unlock();
+ return 0;
+
error:
error:
+ destroy_channel(chan);
+error_alloc:
return ret;
}
return ret;
}
@@
-480,7
+486,7
@@
int ust_registry_session_init(struct ust_registry_session **sessionp,
session = zmalloc(sizeof(*session));
if (!session) {
PERROR("zmalloc ust registry session");
session = zmalloc(sizeof(*session));
if (!session) {
PERROR("zmalloc ust registry session");
- goto error;
+ goto error
_alloc
;
}
pthread_mutex_init(&session->lock, NULL);
}
pthread_mutex_init(&session->lock, NULL);
@@
-516,6
+522,8
@@
int ust_registry_session_init(struct ust_registry_session **sessionp,
return 0;
error:
return 0;
error:
+ ust_registry_session_destroy(session);
+error_alloc:
return -1;
}
return -1;
}
@@
-543,6
+551,8
@@
void ust_registry_session_destroy(struct ust_registry_session *reg)
}
rcu_read_unlock();
}
rcu_read_unlock();
- lttng_ht_destroy(reg->channels);
+ if (reg->channels) {
+ lttng_ht_destroy(reg->channels);
+ }
free(reg->metadata);
}
free(reg->metadata);
}
This page took
0.065317 seconds
and
4
git commands to generate.