phy: exynos5-usbdrd: Fix off-by-one valid value checking for args->args[0]
authorAxel Lin <axel.lin@ingics.com>
Fri, 27 Feb 2015 15:44:24 +0000 (23:44 +0800)
committerKishon Vijay Abraham I <kishon@ti.com>
Fri, 13 Mar 2015 11:44:36 +0000 (17:14 +0530)
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.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
drivers/phy/phy-exynos5-usbdrd.c

index 04374018425f9ab488dea49dd797f68aa5b339c1..e2a0be750ad962d82e2666e5005a8b8daf97f381 100644 (file)
@@ -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;