Skip to content

Commit 13c088c

Browse files
harshimogalapallivinodkoul
authored andcommitted
phy: hisilicon: Fix an out of bounds check in hisi_inno_phy_probe()
The size of array 'priv->ports[]' is INNO_PHY_PORT_NUM. In the for loop, 'i' is used as the index for array 'priv->ports[]' with a check (i > INNO_PHY_PORT_NUM) which indicates that INNO_PHY_PORT_NUM is allowed value for 'i' in the same loop. This > comparison needs to be changed to >=, otherwise it potentially leads to an out of bounds write on the next iteration through the loop Fixes: ba8b0ee ("phy: add inno-usb2-phy driver for hi3798cv200 SoC") Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Harshit Mogalapalli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 8932089 commit 13c088c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/phy/hisilicon/phy-hisi-inno-usb2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static int hisi_inno_phy_probe(struct platform_device *pdev)
184184
phy_set_drvdata(phy, &priv->ports[i]);
185185
i++;
186186

187-
if (i > INNO_PHY_PORT_NUM) {
187+
if (i >= INNO_PHY_PORT_NUM) {
188188
dev_warn(dev, "Support %d ports in maximum\n", i);
189189
of_node_put(child);
190190
break;

0 commit comments

Comments
 (0)