[PATCH v4 038/103] net/ice/base: check if recipe buffer was already allocated
Anatoly Burakov
anatoly.burakov at intel.com
Wed Jun 26 13:41:26 CEST 2024
From: NorbertX Ciosek <norbertx.ciosek 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 f8d98d8a9e..b48f47c846 100644
--- a/drivers/net/ice/base/ice_switch.c
+++ b/drivers/net/ice/base/ice_switch.c
@@ -2573,6 +2573,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