dynamic-array: fix documentation of lttng_dynamic_pointer_array_get_pointer
[lttng-tools.git] / src / common / userspace-probe.c
index 6331ff13574e9f03e14a4dc426284fe97390e526..b6e5083a2907c35836c4b856882004b669feee5b 100644 (file)
@@ -276,6 +276,7 @@ lttng_userspace_probe_location_tracepoint_create_no_check(const char *binary_pat
 error:
        free(probe_name_copy);
        free(provider_name_copy);
+       free(binary_path_copy);
        if (binary_fd >= 0) {
                if (close(binary_fd)) {
                        PERROR("Error closing binary fd in error path");
@@ -404,7 +405,7 @@ lttng_userspace_probe_location_function_copy(
        struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
        const char *binary_path = NULL;
        const char *function_name = NULL;
-       int fd;
+       int fd, new_fd;
 
        assert(location);
        assert(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
@@ -423,8 +424,14 @@ lttng_userspace_probe_location_function_copy(
        }
 
        /* Duplicate the binary fd */
-       fd = dup(lttng_userspace_probe_location_function_get_binary_fd(location));
+       fd = lttng_userspace_probe_location_function_get_binary_fd(location);
        if (fd == -1) {
+               ERR("Error getting file descriptor to binary");
+               goto error;
+       }
+
+       new_fd = dup(fd);
+       if (new_fd == -1) {
                PERROR("Error duplicating file descriptor to binary");
                goto error;
        }
@@ -456,7 +463,7 @@ lttng_userspace_probe_location_function_copy(
        }
 
        /* Set the duplicated fd to the new probe_location */
-       if (lttng_userspace_probe_location_function_set_binary_fd(new_location, fd) < 0) {
+       if (lttng_userspace_probe_location_function_set_binary_fd(new_location, new_fd) < 0) {
                goto destroy_probe_location;
        }
 
@@ -467,7 +474,7 @@ destroy_probe_location:
 destroy_lookup_method:
        lttng_userspace_probe_location_lookup_method_destroy(lookup_method);
 close_fd:
-       if (close(fd) < 0) {
+       if (close(new_fd) < 0) {
                PERROR("Error closing duplicated file descriptor in error path");
        }
 error:
@@ -486,7 +493,7 @@ lttng_userspace_probe_location_tracepoint_copy(
        const char *binary_path = NULL;
        const char *probe_name = NULL;
        const char *provider_name = NULL;
-       int fd;
+       int fd, new_fd;
 
        assert(location);
        assert(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
@@ -511,8 +518,14 @@ lttng_userspace_probe_location_tracepoint_copy(
        }
 
        /* Duplicate the binary fd */
-       fd = dup(lttng_userspace_probe_location_tracepoint_get_binary_fd(location));
+       fd = lttng_userspace_probe_location_tracepoint_get_binary_fd(location);
        if (fd == -1) {
+               ERR("Error getting file descriptor to binary");
+               goto error;
+       }
+
+       new_fd = dup(fd);
+       if (new_fd == -1) {
                PERROR("Error duplicating file descriptor to binary");
                goto error;
        }
@@ -544,7 +557,7 @@ lttng_userspace_probe_location_tracepoint_copy(
        }
 
        /* Set the duplicated fd to the new probe_location */
-       if (lttng_userspace_probe_location_tracepoint_set_binary_fd(new_location, fd) < 0) {
+       if (lttng_userspace_probe_location_tracepoint_set_binary_fd(new_location, new_fd) < 0) {
                goto destroy_probe_location;
        }
 
@@ -555,7 +568,7 @@ destroy_probe_location:
 destroy_lookup_method:
        lttng_userspace_probe_location_lookup_method_destroy(lookup_method);
 close_fd:
-       if (close(fd) < 0) {
+       if (close(new_fd) < 0) {
                PERROR("Error closing duplicated file descriptor in error path");
        }
 error:
This page took 0.025325 seconds and 5 git commands to generate.