Skip to content

Commit

Permalink
fix invalid read on disconnecting anonymous node
Browse files Browse the repository at this point in the history
Fixes: #591

When an anonymous node has been disconnected in the controller
and the cleanup has been done, a log statement was made afterwards.
This statement differed based on the node name. Since the node
instance has been cleaned up (freed), but not set to NULL, valgrind
reported this as an invalid read. Moved the log statements
accordingly.

Signed-off-by: Michael Engel <[email protected]>
  • Loading branch information
engelmi committed Oct 4, 2023
1 parent 1e668bb commit 787686e
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/manager/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,10 +947,11 @@ static int node_disconnected(UNUSED sd_bus_message *message, void *userdata, UNU

/* Remove anonymous nodes when they disconnect */
if (node->name == NULL) {
bc_log_info("Anonymous node disconnected");
manager_remove_node(manager, node);
} else {
/* Remove all jobs associated with the registered node that got
disconnected. */
bc_log_infof("Node '%s' disconnected", node->name);
/* Remove all jobs associated with the registered node that got disconnected. */
if (!LIST_IS_EMPTY(manager->jobs)) {
Job *job = NULL;
Job *next_job = NULL;
Expand All @@ -965,12 +966,6 @@ static int node_disconnected(UNUSED sd_bus_message *message, void *userdata, UNU
node_unset_agent_bus(node);
}

if (node->name) {
bc_log_infof("Node '%s' disconnected", node->name);
} else {
bc_log_info("Anonymous node disconnected");
}

return 0;
}

Expand Down

0 comments on commit 787686e

Please sign in to comment.