* [PATCH lttng-tools] Fix: Memory leaks on error paths in config_read_session_name
[not found] <1362084510-10072-1-git-send-email-christian.babeux@efficios.com>
@ 2013-02-28 20:48 ` Christian Babeux
2013-02-28 20:48 ` [PATCH lttng-tools] Fix: Memory leaks on error paths when exporting consumerd libdir in env Christian Babeux
` (5 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: Christian Babeux @ 2013-02-28 20:48 UTC (permalink / raw)
To: dgoulet; +Cc: lttng-dev
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
---
src/bin/lttng/conf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/bin/lttng/conf.c b/src/bin/lttng/conf.c
index c1bfcfd..7439c1c 100644
--- a/src/bin/lttng/conf.c
+++ b/src/bin/lttng/conf.c
@@ -203,6 +203,7 @@ char *config_read_session_name(char *path)
if (fp == NULL) {
ERR("Can't find valid lttng config %s/.lttngrc", path);
MSG("Did you create a session? (lttng create <my_session>)");
+ free(session_name);
goto error;
}
@@ -221,6 +222,7 @@ char *config_read_session_name(char *path)
}
error_close:
+ free(session_name);
ret = fclose(fp);
if (ret < 0) {
PERROR("close config read session name");
--
1.8.1.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH lttng-tools] Fix: Memory leaks on error paths when exporting consumerd libdir in env
[not found] <1362084510-10072-1-git-send-email-christian.babeux@efficios.com>
2013-02-28 20:48 ` [PATCH lttng-tools] Fix: Memory leaks on error paths in config_read_session_name Christian Babeux
@ 2013-02-28 20:48 ` Christian Babeux
2013-02-28 20:48 ` [PATCH lttng-tools] Fix: Memory leaks on unknown hashtable type error handling Christian Babeux
` (4 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: Christian Babeux @ 2013-02-28 20:48 UTC (permalink / raw)
To: dgoulet; +Cc: lttng-dev
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
---
src/bin/lttng-sessiond/main.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
index e9529f1..82f0a84 100644
--- a/src/bin/lttng-sessiond/main.c
+++ b/src/bin/lttng-sessiond/main.c
@@ -1798,6 +1798,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
ret = putenv(tmpnew);
if (ret) {
ret = -errno;
+ free(tmpnew);
goto error;
}
}
@@ -1842,6 +1843,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
ret = putenv(tmpnew);
if (ret) {
ret = -errno;
+ free(tmpnew);
goto error;
}
}
--
1.8.1.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH lttng-tools] Fix: Memory leaks on unknown hashtable type error handling
[not found] <1362084510-10072-1-git-send-email-christian.babeux@efficios.com>
2013-02-28 20:48 ` [PATCH lttng-tools] Fix: Memory leaks on error paths in config_read_session_name Christian Babeux
2013-02-28 20:48 ` [PATCH lttng-tools] Fix: Memory leaks on error paths when exporting consumerd libdir in env Christian Babeux
@ 2013-02-28 20:48 ` Christian Babeux
2013-02-28 20:48 ` [PATCH lttng-tools] Fix: Memory leaks when calling get_cmdline_by_pid Christian Babeux
` (3 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: Christian Babeux @ 2013-02-28 20:48 UTC (permalink / raw)
To: dgoulet; +Cc: lttng-dev
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
---
src/common/hashtable/hashtable.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/common/hashtable/hashtable.c b/src/common/hashtable/hashtable.c
index 24d5797..5bf85e5 100644
--- a/src/common/hashtable/hashtable.c
+++ b/src/common/hashtable/hashtable.c
@@ -90,6 +90,7 @@ struct lttng_ht *lttng_ht_new(unsigned long size, int type)
break;
default:
ERR("Unknown lttng hashtable type %d", type);
+ lttng_ht_destroy(ht);
goto error;
}
--
1.8.1.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH lttng-tools] Fix: Memory leaks when calling get_cmdline_by_pid
[not found] <1362084510-10072-1-git-send-email-christian.babeux@efficios.com>
` (2 preceding siblings ...)
2013-02-28 20:48 ` [PATCH lttng-tools] Fix: Memory leaks on unknown hashtable type error handling Christian Babeux
@ 2013-02-28 20:48 ` Christian Babeux
2013-02-28 20:48 ` [PATCH lttng-tools] Fix: Memory leak when zmalloc fail on kernel channel allocation Christian Babeux
` (2 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: Christian Babeux @ 2013-02-28 20:48 UTC (permalink / raw)
To: dgoulet; +Cc: lttng-dev
Callers of get_cmdline_by_pid must free(3) the returned string.
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
---
src/bin/lttng/commands/list.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c
index 8fec91f..5429df4 100644
--- a/src/bin/lttng/commands/list.c
+++ b/src/bin/lttng/commands/list.c
@@ -294,6 +294,7 @@ static int list_ust_events(void)
struct lttng_handle *handle;
struct lttng_event *event_list;
pid_t cur_pid = 0;
+ char *cmdline = NULL;
memset(&domain, 0, sizeof(domain));
@@ -322,7 +323,9 @@ static int list_ust_events(void)
for (i = 0; i < size; i++) {
if (cur_pid != event_list[i].pid) {
cur_pid = event_list[i].pid;
- MSG("\nPID: %d - Name: %s", cur_pid, get_cmdline_by_pid(cur_pid));
+ cmdline = get_cmdline_by_pid(cur_pid);
+ MSG("\nPID: %d - Name: %s", cur_pid, cmdline);
+ free(cmdline);
}
print_events(&event_list[i]);
}
@@ -349,6 +352,8 @@ static int list_ust_event_fields(void)
struct lttng_handle *handle;
struct lttng_event_field *event_field_list;
pid_t cur_pid = 0;
+ char *cmdline = NULL;
+
struct lttng_event cur_event;
memset(&domain, 0, sizeof(domain));
@@ -379,7 +384,9 @@ static int list_ust_event_fields(void)
for (i = 0; i < size; i++) {
if (cur_pid != event_field_list[i].event.pid) {
cur_pid = event_field_list[i].event.pid;
- MSG("\nPID: %d - Name: %s", cur_pid, get_cmdline_by_pid(cur_pid));
+ cmdline = get_cmdline_by_pid(cur_pid);
+ MSG("\nPID: %d - Name: %s", cur_pid, cmdline);
+ free(cmdline);
}
if (strcmp(cur_event.name, event_field_list[i].event.name) != 0) {
print_events(&event_field_list[i].event);
--
1.8.1.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH lttng-tools] Fix: Memory leak when zmalloc fail on kernel channel allocation
[not found] <1362084510-10072-1-git-send-email-christian.babeux@efficios.com>
` (3 preceding siblings ...)
2013-02-28 20:48 ` [PATCH lttng-tools] Fix: Memory leaks when calling get_cmdline_by_pid Christian Babeux
@ 2013-02-28 20:48 ` Christian Babeux
2013-02-28 20:48 ` [PATCH lttng-tools] Fix: Use after free on spawn_sessiond error path in check_sessiond Christian Babeux
2013-03-21 17:32 ` [PATCH lttng-tools] Fix: Memory leak on error paths of relay_add_stream David Goulet
6 siblings, 0 replies; 7+ messages in thread
From: Christian Babeux @ 2013-02-28 20:48 UTC (permalink / raw)
To: dgoulet; +Cc: lttng-dev
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
---
src/bin/lttng-sessiond/trace-kernel.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c
index 48be065..8839a00 100644
--- a/src/bin/lttng-sessiond/trace-kernel.c
+++ b/src/bin/lttng-sessiond/trace-kernel.c
@@ -158,6 +158,7 @@ struct ltt_kernel_channel *trace_kernel_create_channel(
lkc->channel = zmalloc(sizeof(struct lttng_channel));
if (lkc->channel == NULL) {
PERROR("lttng_channel zmalloc");
+ free(lkc);
goto error;
}
memcpy(lkc->channel, chan, sizeof(struct lttng_channel));
--
1.8.1.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH lttng-tools] Fix: Use after free on spawn_sessiond error path in check_sessiond
[not found] <1362084510-10072-1-git-send-email-christian.babeux@efficios.com>
` (4 preceding siblings ...)
2013-02-28 20:48 ` [PATCH lttng-tools] Fix: Memory leak when zmalloc fail on kernel channel allocation Christian Babeux
@ 2013-02-28 20:48 ` Christian Babeux
2013-03-21 17:32 ` [PATCH lttng-tools] Fix: Memory leak on error paths of relay_add_stream David Goulet
6 siblings, 0 replies; 7+ messages in thread
From: Christian Babeux @ 2013-02-28 20:48 UTC (permalink / raw)
To: dgoulet; +Cc: lttng-dev
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
---
src/bin/lttng/lttng.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c
index 8562144..be673f9 100644
--- a/src/bin/lttng/lttng.c
+++ b/src/bin/lttng/lttng.c
@@ -374,13 +374,12 @@ static int check_sessiond(void)
}
ret = spawn_sessiond(pathname);
- free(alloc_pathname);
if (ret < 0) {
ERR("Problem occurred when starting %s", pathname);
- goto end;
}
- }
+ free(alloc_pathname);
+ }
end:
return ret;
}
--
1.8.1.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH lttng-tools] Fix: Memory leak on error paths of relay_add_stream
[not found] <1362084510-10072-1-git-send-email-christian.babeux@efficios.com>
` (5 preceding siblings ...)
2013-02-28 20:48 ` [PATCH lttng-tools] Fix: Use after free on spawn_sessiond error path in check_sessiond Christian Babeux
@ 2013-03-21 17:32 ` David Goulet
6 siblings, 0 replies; 7+ messages in thread
From: David Goulet @ 2013-03-21 17:32 UTC (permalink / raw)
To: Christian Babeux; +Cc: lttng-dev
Merged all 7!
David
Christian Babeux:
> On error paths the memory allocated for stream is never freed.
>
> Also, fix undefined behavior on asprintf alloc failure. According to
> asprintf(3), the content of the pointer passed to it is undefined if
> an alloc failure occurs, so we could end up freeing a pointer in an
> undefined state. Force its value to NULL.
>
> Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
> ---
> src/bin/lttng-relayd/main.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c
> index 4f9d742..00b7ea3 100644
> --- a/src/bin/lttng-relayd/main.c
> +++ b/src/bin/lttng-relayd/main.c
> @@ -941,6 +941,7 @@ int relay_add_stream(struct lttcomm_relayd_hdr *recv_hdr,
> ret = asprintf(&path, "%s/%s", root_path, stream_info.channel_name);
> if (ret < 0) {
> PERROR("asprintf stream path");
> + path = NULL;
> goto end;
> }
>
> @@ -963,13 +964,17 @@ int relay_add_stream(struct lttcomm_relayd_hdr *recv_hdr,
> end:
> free(path);
> free(root_path);
> +
> + reply.handle = htobe64(stream->stream_handle);
> /* send the session id to the client or a negative return code on error */
> if (ret < 0) {
> reply.ret_code = htobe32(LTTNG_ERR_UNK);
> + /* stream was not properly added to the ht, so free it */
> + free(stream);
> } else {
> reply.ret_code = htobe32(LTTNG_OK);
> }
> - reply.handle = htobe64(stream->stream_handle);
> +
> send_ret = cmd->sock->ops->sendmsg(cmd->sock, &reply,
> sizeof(struct lttcomm_relayd_status_stream), 0);
> if (send_ret < 0) {
^ permalink raw reply [flat|nested] 7+ messages in thread