summaryrefslogtreecommitdiff
path: root/lib/graph
diff options
context:
space:
mode:
authorZhirun Yan <[email protected]>2022-08-04 14:02:41 +0800
committerThomas Monjalon <[email protected]>2022-10-10 17:30:39 +0200
commitafe67d1414a81004eae5a50561c724a36b025960 (patch)
tree86b5238beb6122f2e00dad92742dbb6a990f1730 /lib/graph
parent90cf759aafeffb884cb0d88bb24fda833245eaa1 (diff)
graph: fix node objects allocation
For __rte_node_enqueue_prologue(), if the number of objs is more than the node->size * 2, the extra objs will write out of bounds memory. It should use __rte_node_stream_alloc_size() to request enough memory. And for rte_node_next_stream_put(), it will re-allocate a small size, when the node free space is small and new objs is less than the current node->size. Some objs pointers behind new size may be lost. And it will cause memory leak. It should request enough size of memory, containing the original objs and new objs at least. Fixes: 40d4f51403ec ("graph: implement fastpath routines") Cc: [email protected] Signed-off-by: Zhirun Yan <[email protected]> Signed-off-by: Cunming Liang <[email protected]> Acked-by: Jerin Jacob <[email protected]>
Diffstat (limited to 'lib/graph')
-rw-r--r--lib/graph/rte_graph_worker.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/graph/rte_graph_worker.h b/lib/graph/rte_graph_worker.h
index 0c0b9c095a..6dc7461659 100644
--- a/lib/graph/rte_graph_worker.h
+++ b/lib/graph/rte_graph_worker.h
@@ -224,7 +224,7 @@ __rte_node_enqueue_prologue(struct rte_graph *graph, struct rte_node *node,
__rte_node_enqueue_tail_update(graph, node);
if (unlikely(node->size < (idx + space)))
- __rte_node_stream_alloc(graph, node);
+ __rte_node_stream_alloc_size(graph, node, node->size + space);
}
/**
@@ -432,7 +432,7 @@ rte_node_next_stream_get(struct rte_graph *graph, struct rte_node *node,
uint16_t free_space = node->size - idx;
if (unlikely(free_space < nb_objs))
- __rte_node_stream_alloc_size(graph, node, nb_objs);
+ __rte_node_stream_alloc_size(graph, node, node->size + nb_objs);
return &node->objs[idx];
}