From: Long Wu <long...@corigine.com>

CI found that overrunning array of 32 2-byte elements at
element index 65535 (byte offset 131071) by dereferencing
pointer "members + agg_new_idx".

Coverity issue: 403099
Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
Cc: danielx.t.mrzyg...@intel.com
Cc: sta...@dpdk.org

Signed-off-by: Long Wu <long...@corigine.com>
Reviewed-by: Chaoyong He <chaoyong...@corigine.com>
Reviewed-by: Peng Zhang <peng.zh...@corigine.com>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c 
b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 677067870f..0be33f61e3 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -732,10 +732,14 @@ selection_logic(struct bond_dev_private *internals, 
uint16_t member_id)
        switch (internals->mode4.agg_selection) {
        case AGG_COUNT:
                agg_new_idx = max_index(agg_count, members_count);
+               if (agg_new_idx >= members_count)
+                       agg_new_idx = default_member;
                new_agg_id = members[agg_new_idx];
                break;
        case AGG_BANDWIDTH:
                agg_new_idx = max_index(agg_bandwidth, members_count);
+               if (agg_new_idx >= members_count)
+                       agg_new_idx = default_member;
                new_agg_id = members[agg_new_idx];
                break;
        case AGG_STABLE:
-- 
2.39.1

Reply via email to