diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2019-07-31 00:49:00 +0300 |
---|---|---|
committer | Joe Hershberger <joe.hershberger@ni.com> | 2019-09-04 19:37:19 +0300 |
commit | fd6d88f55baee946d2a1bd16e7344486cf140c94 (patch) | |
tree | 0a9981ad65b2728f969f47573a82a7a2ca683720 /drivers | |
parent | a37c082248220a30caacc7804575cae6f885506b (diff) | |
download | u-boot-fd6d88f55baee946d2a1bd16e7344486cf140c94.tar.xz |
test: dm_mdio: avoid out of bounds access
SANDBOX_PHY_REG_CNT is not an allowable index for the array
u16 reg[SANDBOX_PHY_REG_CNT].
Identified by cppcheck.
Fixes: b47edf8069cc ("test: dm_mdio: add a 2nd register to the emulated PHY")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/mdio_sandbox.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/mdio_sandbox.c b/drivers/net/mdio_sandbox.c index df053f5381..b731f60a98 100644 --- a/drivers/net/mdio_sandbox.c +++ b/drivers/net/mdio_sandbox.c @@ -27,7 +27,7 @@ static int mdio_sandbox_read(struct udevice *dev, int addr, int devad, int reg) return -ENODEV; if (devad != MDIO_DEVAD_NONE) return -ENODEV; - if (reg < 0 || reg > SANDBOX_PHY_REG_CNT) + if (reg < 0 || reg >= SANDBOX_PHY_REG_CNT) return -ENODEV; return priv->reg[reg]; @@ -45,7 +45,7 @@ static int mdio_sandbox_write(struct udevice *dev, int addr, int devad, int reg, return -ENODEV; if (devad != MDIO_DEVAD_NONE) return -ENODEV; - if (reg < 0 || reg > SANDBOX_PHY_REG_CNT) + if (reg < 0 || reg >= SANDBOX_PHY_REG_CNT) return -ENODEV; priv->reg[reg] = val; |