X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist.c;h=4a53968740bd789aa8216bfda39029396c346b72;hp=b73d5209f7f023408048fa27f90f9e0a3a45aeb3;hb=aa5de748c1150c17624abce3cc74839fea3234f6;hpb=441c16a7f0bbab56a5e783059d0cddab68544a9a diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index b73d5209f..4a5396874 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -260,6 +260,7 @@ static int list_ust_events(void) size = lttng_list_tracepoints(handle, &event_list); if (size < 0) { ERR("Unable to list UST events"); + lttng_destroy_handle(handle); return size; } @@ -280,10 +281,12 @@ static int list_ust_events(void) MSG(""); free(event_list); + lttng_destroy_handle(handle); return CMD_SUCCESS; error: + lttng_destroy_handle(handle); return -1; } @@ -311,6 +314,7 @@ static int list_kernel_events(void) size = lttng_list_tracepoints(handle, &event_list); if (size < 0) { ERR("Unable to list kernel events"); + lttng_destroy_handle(handle); return size; } @@ -324,9 +328,11 @@ static int list_kernel_events(void) free(event_list); + lttng_destroy_handle(handle); return CMD_SUCCESS; error: + lttng_destroy_handle(handle); return -1; } @@ -600,10 +606,12 @@ int cmd_list(int argc, const char **argv) domain.type = LTTNG_DOMAIN_UST; } - handle = lttng_create_handle(session_name, &domain); - if (handle == NULL) { - ret = CMD_FATAL; - goto end; + if (opt_kernel || opt_userspace) { + handle = lttng_create_handle(session_name, &domain); + if (handle == NULL) { + ret = CMD_FATAL; + goto end; + } } if (session_name == NULL) { @@ -666,7 +674,9 @@ int cmd_list(int argc, const char **argv) } /* Clean handle before creating a new one */ - lttng_destroy_handle(handle); + if (handle) { + lttng_destroy_handle(handle); + } handle = lttng_create_handle(session_name, &domains[i]); if (handle == NULL) { @@ -686,7 +696,9 @@ end: if (domains) { free(domains); } - lttng_destroy_handle(handle); + if (handle) { + lttng_destroy_handle(handle); + } poptFreeContext(pc); return ret;