]> Git Repo - linux.git/commitdiff
phy: hisilicon: Fix an out of bounds check in hisi_inno_phy_probe()
authorHarshit Mogalapalli <[email protected]>
Fri, 21 Jul 2023 09:05:55 +0000 (02:05 -0700)
committerVinod Koul <[email protected]>
Mon, 24 Jul 2023 10:53:37 +0000 (16:23 +0530)
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: ba8b0ee81fbb ("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]>
drivers/phy/hisilicon/phy-hisi-inno-usb2.c

index 15dafe359552c9242a1596225a7191e81d1b745f..6ae6d509dfdd82edf3bf3425d685c077ff901a54 100644 (file)
@@ -184,7 +184,7 @@ static int hisi_inno_phy_probe(struct platform_device *pdev)
                phy_set_drvdata(phy, &priv->ports[i]);
                i++;
 
-               if (i > INNO_PHY_PORT_NUM) {
+               if (i >= INNO_PHY_PORT_NUM) {
                        dev_warn(dev, "Support %d ports in maximum\n", i);
                        of_node_put(child);
                        break;
This page took 0.059094 seconds and 4 git commands to generate.