[PATCH v2 005/148] net/ice/base: fix for pointer to variable outside scope

Anatoly Burakov anatoly.burakov at intel.com
Wed Jun 12 16:59:59 CEST 2024


From: Ian Stokes <ian.stokes at intel.com>

Currently, the 'temp' variable is in the same scope as 'first_teid_ptr'
and we take point to it, which means on new loop iterations the memory
goes out of scope and we keep a dangling pointer. Move 'temp' to
outside of the loop to fix it.

Signed-off-by: Stefan Wegrzyn <stefan.wegrzyn at intel.com>
Signed-off-by: Ian Stokes <ian.stokes at intel.com>
---
 drivers/net/ice/base/ice_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ice/base/ice_sched.c b/drivers/net/ice/base/ice_sched.c
index d694bfd414..c9d70fb043 100644
--- a/drivers/net/ice/base/ice_sched.c
+++ b/drivers/net/ice/base/ice_sched.c
@@ -1069,11 +1069,11 @@ ice_sched_add_nodes_to_layer(struct ice_port_info *pi,
 	u32 *first_teid_ptr = first_node_teid;
 	u16 new_num_nodes = num_nodes;
 	int status = 0;
+	u32 temp;
 
 	*num_nodes_added = 0;
 	while (*num_nodes_added < num_nodes) {
 		u16 max_child_nodes, num_added = 0;
-		u32 temp;
 
 		status = ice_sched_add_nodes_to_hw_layer(pi, tc_node, parent,
 							 layer,	new_num_nodes,
-- 
2.43.0



More information about the dev mailing list