[PATCH v2 080/148] net/ice/base: check array bounds
Anatoly Burakov
anatoly.burakov at intel.com
Wed Jun 12 17:01:14 CEST 2024
From: Ian Stokes <ian.stokes at intel.com>
Some compilation targets were generating errors due to unchecked array bounds
when accessing recipe groups. Add a check to avoid that.
Signed-off-by: Waldemar Dworakowski <waldemar.dworakowski at intel.com>
Signed-off-by: Ian Stokes <ian.stokes at intel.com>
---
drivers/net/ice/base/ice_switch.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c
index 9ea302585c..051cf087f5 100644
--- a/drivers/net/ice/base/ice_switch.c
+++ b/drivers/net/ice/base/ice_switch.c
@@ -7533,12 +7533,14 @@ ice_create_first_fit_recp_def(struct ice_hw *hw,
(*recp_cnt)++;
}
- grp->pairs[grp->n_val_pairs].prot_id =
- lkup_exts->fv_words[j].prot_id;
- grp->pairs[grp->n_val_pairs].off =
- lkup_exts->fv_words[j].off;
- grp->mask[grp->n_val_pairs] = lkup_exts->field_mask[j];
- grp->n_val_pairs++;
+ if (grp->n_val_pairs < ICE_NUM_WORDS_RECIPE) {
+ grp->pairs[grp->n_val_pairs].prot_id =
+ lkup_exts->fv_words[j].prot_id;
+ grp->pairs[grp->n_val_pairs].off =
+ lkup_exts->fv_words[j].off;
+ grp->mask[grp->n_val_pairs] = lkup_exts->field_mask[j];
+ grp->n_val_pairs++;
+ }
}
return 0;
--
2.43.0
More information about the dev
mailing list