[PATCH v2 075/148] net/ice/base: check if recipe buffer was already allocated

Anatoly Burakov anatoly.burakov at intel.com
Wed Jun 12 17:01:09 CEST 2024


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

Check if recipe buffer was already allocated before allocating new one.
Without such check it is possible to get memory leak when overwriting
pointer address.

Signed-off-by: NorbertX Ciosek <norbertx.ciosek at intel.com>
Signed-off-by: Ian Stokes <ian.stokes at intel.com>
---
 drivers/net/ice/base/ice_switch.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c
index 62f86aaf13..9d576cabf6 100644
--- a/drivers/net/ice/base/ice_switch.c
+++ b/drivers/net/ice/base/ice_switch.c
@@ -2577,6 +2577,9 @@ ice_get_recp_frm_fw(struct ice_hw *hw, struct ice_sw_recipe *recps, u8 rid,
 	recps[rid].big_recp = (num_recps > 1);
 	recps[rid].n_grp_count = (u8)num_recps;
 	recps[rid].tun_type = ice_get_tun_type_for_recipe(rid, vlan);
+	if (recps[rid].root_buf)
+		ice_free(hw, recps[rid].root_buf);
+
 	recps[rid].root_buf = (struct ice_aqc_recipe_data_elem *)
 		ice_memdup(hw, tmp, recps[rid].n_grp_count *
 			   sizeof(*recps[rid].root_buf), ICE_NONDMA_TO_NONDMA);
-- 
2.43.0



More information about the dev mailing list