Skip to content

Commit e4308bc

Browse files
Mikhail Kobukvinodkoul
authored andcommitted
phy: marvell: a3700-comphy: Fix out of bounds read
There is an out of bounds read access of 'gbe_phy_init_fix[fix_idx].addr' every iteration after 'fix_idx' reaches 'ARRAY_SIZE(gbe_phy_init_fix)'. Make sure 'gbe_phy_init[addr]' is used when all elements of 'gbe_phy_init_fix' array are handled. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 9343370 ("phy: marvell: phy-mvebu-a3700-comphy: Add native kernel implementation") Signed-off-by: Mikhail Kobuk <[email protected]> Reviewed-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 4cece76 commit e4308bc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/phy/marvell/phy-mvebu-a3700-comphy.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,12 @@ static void comphy_gbe_phy_init(struct mvebu_a3700_comphy_lane *lane,
611611
* comparison to 3.125 Gbps values. These register values are
612612
* stored in "gbe_phy_init_fix" array.
613613
*/
614-
if (!is_1gbps && gbe_phy_init_fix[fix_idx].addr == addr) {
614+
if (!is_1gbps &&
615+
fix_idx < ARRAY_SIZE(gbe_phy_init_fix) &&
616+
gbe_phy_init_fix[fix_idx].addr == addr) {
615617
/* Use new value */
616618
val = gbe_phy_init_fix[fix_idx].value;
617-
if (fix_idx < ARRAY_SIZE(gbe_phy_init_fix))
618-
fix_idx++;
619+
fix_idx++;
619620
} else {
620621
val = gbe_phy_init[addr];
621622
}

0 commit comments

Comments
 (0)