Skip to content

Commit dbd07a0

Browse files
committed
core: fix former child parent pointers when putting back
When we fail to insert an object because of intersect errors, we may have moved some children below it already. when putting them back to their former parent, don't forget to update their parent pointer. Updating the failed-object parent is however unneeded, it'll be dropped soon. Signed-off-by: Brice Goglin <[email protected]>
1 parent 148d70a commit dbd07a0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

hwloc/topology.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,9 @@ hwloc___insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t cur
14851485
return obj;
14861486

14871487
putback:
1488-
/* Put-back OBJ children in CUR and return an error. */
1488+
/* OBJ cannot be inserted.
1489+
* Put-back OBJ children in CUR and return an error.
1490+
*/
14891491
if (putp)
14901492
cur_children = putp; /* No need to try to insert before where OBJ was supposed to go */
14911493
else
@@ -1494,12 +1496,12 @@ hwloc___insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t cur
14941496
while ((child = obj->first_child) != NULL) {
14951497
/* Remove from OBJ */
14961498
obj->first_child = child->next_sibling;
1497-
obj->parent = cur;
1498-
/* Find child position in CUR, and insert. */
1499+
/* Find child position in CUR, and reinsert it. */
14991500
while (*cur_children && hwloc__object_cpusets_compare_first(*cur_children, child) < 0)
15001501
cur_children = &(*cur_children)->next_sibling;
15011502
child->next_sibling = *cur_children;
15021503
*cur_children = child;
1504+
child->parent = cur;
15031505
}
15041506
return NULL;
15051507
}

0 commit comments

Comments
 (0)