Checks
Context | Check | Description |
---|---|---|
ci/checkpatch | success | coding style OK |
Commit Message
Burakov, Anatoly
June 12, 2024, 3:01 p.m. UTC
From: Ian Stokes <ian.stokes@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@intel.com> Signed-off-by: Ian Stokes <ian.stokes@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);