Skip to contentSkip to conversation

phy: exynos5-usbdrd: Fix off-by-one valid value checking for args->args[0]

PATCH In review Axel Lin 2 participants 2 messages Feb 27, 2015 – Mar 2, 2015

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 phy: exynos5-usbdrd: Fix off-by-one valid value checking for args->args[0]

Current code uses args->args[0] as array subscript of phy_drd->phys[]. So the valid value range for args->args[0] is 0 ... EXYNOS5_DRDPHYS_NUM - 1.

---
 drivers/phy/phy-exynos5-usbdrd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-exynos5-usbdrd.c +1 -1
index 0437401..e2a0be7 100644
@@ -531,7 +531,7 @@ static struct phy *exynos5_usbdrd_phy_xlate(struct device *dev,
 {
 	struct exynos5_usbdrd_phy *phy_drd = dev_get_drvdata(dev);
 
-	if (WARN_ON(args->args[0] > EXYNOS5_DRDPHYS_NUM))
+	if (WARN_ON(args->args[0] >= EXYNOS5_DRDPHYS_NUM))
 		return ERR_PTR(-ENODEV);
 
 	return phy_drd->phys[args->args[0]].phy;
Signature · 1 line
1.9.1
#1 lore raw

Hi,

Quoted 4 lines · Axel Lin

Current code uses args->args[0] as array subscript of phy_drd->phys[]. So the valid value range for args->args[0] is 0 ... EXYNOS5_DRDPHYS_NUM - 1.

Reviewed by: Vivek Gautam <[email protected]>

Quoted 17 lines

---
drivers/phy/phy-exynos5-usbdrd.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-exynos5-usbdrd.c +1 -1
index 0437401..e2a0be7 100644
@@ -531,7 +531,7 @@ static struct phy *exynos5_usbdrd_phy_xlate(struct 
 device *dev,
 {
 struct exynos5_usbdrd_phy *phy_drd = dev_get_drvdata(dev);
 
- if (WARN_ON(args->args[0] > EXYNOS5_DRDPHYS_NUM))
+ if (WARN_ON(args->args[0] >= EXYNOS5_DRDPHYS_NUM))
 return ERR_PTR(-ENODEV);
 
Quoted 4 lines

return phy_drd->phys[args->args[0]].phy;

Signature · 1 line
1.9.1

BRs
Vivek