1452630 Resource leak
The system resource will not be reclaimed and reused, reducing the
future availability of the resource.
In lttng_error_query_action_create: Leak of memory or pointers to system
resources (CWE-404)
CID
1452630 (#1 of 1): Resource leak (RESOURCE_LEAK)
21. leaked_storage: Variable trigger_copy going out of scope leaks the
storage it points to.
Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4dd99390f1fd5ad957ab6500971dd2ed67a1c722
const struct lttng_trigger *trigger)
{
struct lttng_error_query_trigger *query = NULL;
const struct lttng_trigger *trigger)
{
struct lttng_error_query_trigger *query = NULL;
- struct lttng_trigger *trigger_copy;
+ struct lttng_trigger *trigger_copy = NULL;
- trigger_copy = lttng_trigger_copy(trigger);
- if (!trigger_copy) {
+ trigger_copy = lttng_trigger_copy(trigger);
+ if (!trigger_copy) {
goto end;
}
query = zmalloc(sizeof(*query));
if (!query) {
PERROR("Failed to allocate trigger error query");
goto end;
}
query = zmalloc(sizeof(*query));
if (!query) {
PERROR("Failed to allocate trigger error query");
}
query->parent.target_type = LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER;
query->trigger = trigger_copy;
}
query->parent.target_type = LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER;
query->trigger = trigger_copy;
+ trigger_copy = NULL;
+
+error:
+ lttng_trigger_put(trigger_copy);
end:
return query ? &query->parent : NULL;
}
end:
return query ? &query->parent : NULL;
}
{
struct lttng_error_query_action *query = NULL;
typeof(query->action_index) action_index;
{
struct lttng_error_query_action *query = NULL;
typeof(query->action_index) action_index;
- struct lttng_trigger *trigger_copy;
+ struct lttng_trigger *trigger_copy = NULL;
if (!trigger || !action) {
goto end;
if (!trigger || !action) {
goto end;
action_status = lttng_action_group_get_count(
trigger->action, &action_group_count);
if (action_status != LTTNG_ACTION_STATUS_OK) {
action_status = lttng_action_group_get_count(
trigger->action, &action_group_count);
if (action_status != LTTNG_ACTION_STATUS_OK) {
}
for (i = 0; i < action_group_count; i++) {
}
for (i = 0; i < action_group_count; i++) {
if (!action_index.is_set) {
/* Not found; invalid action. */
if (!action_index.is_set) {
/* Not found; invalid action. */
}
} else {
/*
* Trigger action is not a group and not equal to the target
* action; invalid action provided.
*/
}
} else {
/*
* Trigger action is not a group and not equal to the target
* action; invalid action provided.
*/
}
query = zmalloc(sizeof(*query));
if (!query) {
PERROR("Failed to allocate action error query");
}
query = zmalloc(sizeof(*query));
if (!query) {
PERROR("Failed to allocate action error query");
}
query->parent.target_type = LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION;
query->trigger = trigger_copy;
}
query->parent.target_type = LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION;
query->trigger = trigger_copy;
query->action_index = action_index;
query->action_index = action_index;
+error:
+ lttng_trigger_put(trigger_copy);
end:
return query ? &query->parent : NULL;
}
end:
return query ? &query->parent : NULL;
}