graph: fix node shrink
PATCH 1/1 graph: fix node shrink
If the node id check failed, graph_lock was not taken before releasing.
--- lib/graph/node.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/graph/node.c +4 -4
@@ -300,16 +300,16 @@ rte_node_edge_shrink(rte_node_t id, rte_edge_t size)if (node->id == id) {if (node->nb_edges < size) { rte_errno =E2BIG ; - goto fail; + }else { + node->nb_edges = size; + rc = size; } - node->nb_edges = size; - rc = size;break ; } } -fail:graph_spinlock_unlock (); +fail:return rc; }
Signature · 1 line
2.39.0
Quoted 14 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: 19 January 2023 04:03 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Nithin Kumar Dabilpuram <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>
Subject: [EXT] [PATCH] graph: fix node shrinkExternal Email
Quoted 7 lines
----------------------------------------------------------------------
If the node id check failed,graph_lockwas not taken before releasing.Fixes c59dac2ca14a ("graph: implement node operations")Signed-off-by David Marchand <[email protected]>
Quoted 32 lines
--- lib/graph/node.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)lib/graph/node.c index fc6345de07..149414dcd9 renamed from lib/graph/node.c +0
-0100644
lib/graph/node.c +4
-5@@ -300,16 +300,16 @@ rte_node_edge_shrink(rte_node_t id, rte_edge_t size)if (node->id == id) {if (node->nb_edges < size) { rte_errno =E2BIG ; - goto fail; + }else { + node->nb_edges = size; + rc = size; } - node->nb_edges = size; - rc = size;break ; } } -fail:graph_spinlock_unlock (); +fail:return rc; } --2.39.0
Quoted 2 lines · David Marchand
If the node id check failed,
graph_lockwas not taken before releasing.
Thanks for the fix.
Why not this oneline fix?
[main][dpdk.org] $ git diff
lib/graph/node.c +1 -1
@@ -293,8 +293,8 @@ rte_node_edge_shrink(rte_node_t id, rte_edge_t size)rte_edge_t rc =RTE_EDGE_ID_INVALID ;struct node *node; -NODE_ID_CHECK (id);graph_spinlock_lock (); +NODE_ID_CHECK (id); STAILQ_FOREACH(node, &node_list, next) {if (node->id == id) {
Quoted 37 lines
Fixes c59dac2ca14a ("graph: implement node operations")Signed-off-by David Marchand <[email protected]>--- lib/graph/node.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)lib/graph/node.c +4
-5@@ -300,16 +300,16 @@ rte_node_edge_shrink(rte_node_t id, rte_edge_t size)if (node->id == id) {if (node->nb_edges < size) { rte_errno =E2BIG ; - goto fail; + }else { + node->nb_edges = size; + rc = size; } - node->nb_edges = size; - rc = size;break ; } } -fail:graph_spinlock_unlock (); +fail:return rc; } --2.39.0
Quoted 17 lines · Jerin Jacob
Quoted 2 lines · David Marchand
If the node id check failed,
graph_lockwas not taken before releasing.Thanks for the fix.
Why not this oneline fix?
[main][dpdk.org] $ git diff
lib/graph/node.c +0
-0
lib/graph/node.c rte_node_edge_shrink(rte_node_t id, rte_edge_t size) · line 300
Quoted 9 lines
lib/graph/node.c +1
-1@@ -293,8 +293,8 @@ rte_node_edge_shrink(rte_node_t id, rte_edge_t size)rte_edge_t rc =RTE_EDGE_ID_INVALID ;struct node *node; -NODE_ID_CHECK (id);graph_spinlock_lock (); +NODE_ID_CHECK (id); STAILQ_FOREACH(node, &node_list, next) {if (node->id == id) {
Other calls to NODE_ID_CHECK input check are done out of the lock. And to keep consistency with the rest of this library code.
Signature · 1 line
David Marchand
Jerin Jacob
Acked-byQuoted 26 lines · David Marchand
Quoted 24 lines · Jerin Jacob
Quoted 2 lines · David Marchand
If the node id check failed,
graph_lockwas not taken before releasing.Thanks for the fix.
Why not this oneline fix?
[main][dpdk.org] $ git diff
lib/graph/node.c +1
-1@@ -293,8 +293,8 @@ rte_node_edge_shrink(rte_node_t id, rte_edge_t size)rte_edge_t rc =RTE_EDGE_ID_INVALID ;struct node *node; -NODE_ID_CHECK (id);graph_spinlock_lock (); +NODE_ID_CHECK (id);
Quoted 5 lines
lib/graph/node.c rte_node_edge_shrink(rte_node_t id, rte_edge_t size) · line 300
Quoted 2 lines
lib/graph/node.c +0
-0STAILQ_FOREACH(node, &node_list, next) {if (node->id == id) {Other calls to
NODE_ID_CHECKinput check are done out of the lock. And to keep consistency with the rest of this library code.
Quoted 4 lines
--
David Marchand
Quoted 6 lines · David Marchand
If the node id check failed,
graph_lockwas not taken before releasing.Fixes c59dac2ca14a ("graph: implement node operations")
Quoted 8 lines
Signed-off-by David Marchand <[email protected]>If the node id check failed,
graph_lockwas not taken before releasing.Fixes c59dac2ca14a ("graph: implement node operations")Signed-off-by David Marchand <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand