/*
- * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License, version 2.1 only,
- * as published by the Free Software Foundation.
+ * SPDX-License-Identifier: LGPL-2.1-only
*
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <assert.h>
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");
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);
}
/* 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;
}
}
/* 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;
}
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:
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);
}
/* 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;
}
}
/* 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;
}
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: