Fix: lttng: leak of userspace probe path on listing
[lttng-tools.git] / src / bin / lttng / commands / list.c
index 28166c8be28e5a9588d14d8f14adfd56a39810dd..fa7e044601822a710d425af40546d3d17d7f6590 100644 (file)
@@ -279,7 +279,7 @@ static void print_userspace_probe_location(struct lttng_event *event)
        case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
        {
                const char *function_name;
-               const char *binary_path;
+               char *binary_path;
 
                MSG("%sType: Function", indent8);
                function_name = lttng_userspace_probe_location_function_get_function_name(location);
@@ -298,12 +298,14 @@ static void print_userspace_probe_location(struct lttng_event *event)
                        MSG("%sLookup method: INVALID LOOKUP TYPE ENCOUNTERED", indent8);
                        break;
                }
+
+               free(binary_path);
                break;
        }
        case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
        {
                const char *probe_name, *provider_name;
-               const char *binary_path;
+               char *binary_path;
 
                MSG("%sType: Tracepoint", indent8);
                probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(location);
@@ -319,6 +321,8 @@ static void print_userspace_probe_location(struct lttng_event *event)
                        MSG("%sLookup method: INVALID LOOKUP TYPE ENCOUNTERED", indent8);
                        break;
                }
+
+               free(binary_path);
                break;
        }
        default:
@@ -1452,7 +1456,6 @@ static int list_channels(const char *channel_name)
                                count = 0;
                        } else {
                                ret = CMD_SUCCESS;
-                               WARN("No kernel channel");
                                goto error_channels;
                        }
                        break;
@@ -1825,7 +1828,7 @@ static int list_sessions(const char *session_name)
        int ret = CMD_SUCCESS;
        int count, i;
        unsigned int session_found = 0;
-       struct lttng_session *sessions;
+       struct lttng_session *sessions = NULL;
 
        count = lttng_list_sessions(&sessions);
        DBG("Session count %d", count);
@@ -1838,7 +1841,7 @@ static int list_sessions(const char *session_name)
        if (lttng_opt_mi) {
                /* Mi */
                if (session_name == NULL) {
-                       /* List all session */
+                       /* List all sessions */
                        ret = mi_list_sessions(sessions, count);
                } else {
                        /* Note : this return an open session element */
@@ -1846,7 +1849,7 @@ static int list_sessions(const char *session_name)
                }
                if (ret) {
                        ret = CMD_ERROR;
-                       goto error;
+                       goto end;
                }
        } else {
                /* Pretty print */
@@ -1893,7 +1896,7 @@ static int list_sessions(const char *session_name)
                if (!session_found && session_name != NULL) {
                        ERR("Session '%s' not found", session_name);
                        ret = CMD_ERROR;
-                       goto error;
+                       goto end;
                }
 
                if (session_name == NULL) {
@@ -1901,9 +1904,8 @@ static int list_sessions(const char *session_name)
                }
        }
 
-error:
-       free(sessions);
 end:
+       free(sessions);
        return ret;
 }
 
This page took 0.024965 seconds and 4 git commands to generate.