]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
octeontx2-af: Add array index check
authorAleksandr Mishin <amishin@t-argos.ru>
Thu, 28 Mar 2024 16:55:05 +0000 (19:55 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 3 Apr 2024 10:00:33 +0000 (11:00 +0100)
In rvu_map_cgx_lmac_pf() the 'iter', which is used as an array index, can reach
value (up to 14) that exceed the size (MAX_LMAC_COUNT = 8) of the array.
Fix this bug by adding 'iter' value check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 91c6945ea1f9 ("octeontx2-af: cn10k: Add RPM MAC support")
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c

index 72e060cf6b6181d9ccd22b2f3a126c6b7f063a83..e9bf9231b0185db5113f99455ad50d31f8e432d5 100644 (file)
@@ -160,6 +160,8 @@ static int rvu_map_cgx_lmac_pf(struct rvu *rvu)
                        continue;
                lmac_bmap = cgx_get_lmac_bmap(rvu_cgx_pdata(cgx, rvu));
                for_each_set_bit(iter, &lmac_bmap, rvu->hw->lmac_per_cgx) {
+                       if (iter >= MAX_LMAC_COUNT)
+                               continue;
                        lmac = cgx_get_lmacid(rvu_cgx_pdata(cgx, rvu),
                                              iter);
                        rvu->pf2cgxlmac_map[pf] = cgxlmac_id_to_bmap(cgx, lmac);