From patchwork Fri Feb 27 15:44:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 5901511 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E5F149F37F for ; Fri, 27 Feb 2015 15:44:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 26E472028D for ; Fri, 27 Feb 2015 15:44:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5026920270 for ; Fri, 27 Feb 2015 15:44:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754624AbbB0Pob (ORCPT ); Fri, 27 Feb 2015 10:44:31 -0500 Received: from mail-pd0-f171.google.com ([209.85.192.171]:33085 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754200AbbB0Pob (ORCPT ); Fri, 27 Feb 2015 10:44:31 -0500 Received: by pdjz10 with SMTP id z10so21916189pdj.0 for ; Fri, 27 Feb 2015 07:44:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=Mj6rfzqUfjnL7kqOQRG5KWWTmCj24Y1hqaNq4i+vF1s=; b=eRPa7x4JUOuGM6Lnba+UZG84TTxTTZqFCn7XgNmklS9H0UJ0VBdBW/HDPnF1AEqqsl Jhxh4QO8htzLKTlkdo3Zx/vppTLbaNZwyi6pG4vuIB0Rw1kBGVC/dzPeni1PLSChrUCz g4rnl/A1y6WKGgP12h6hBfghzBPbfmuKJUUklqA3m3GWoS4wYsG8uabclNmFRggUiQ25 QPaNWFdxFkJD76w61/xplEQL7DsOiQhw6Mc4vsuaKF91BIPL3AFs8XSRq8Has/EKkDVA qlpZ0nvV6m3E3CoY1amGPm9wi/eqcon3WQRtip9iv27DD16KkzZ8qOXLFEs4i+zsG7gk 3lLA== X-Gm-Message-State: ALoCoQlmI4RPgYcEUO3Oq31f18bjL53Cr+MQ3WaJXOnSCoiIUvuI784gJ5IL6S0kczD0HiN1kEHp X-Received: by 10.66.101.35 with SMTP id fd3mr25469485pab.50.1425051870470; Fri, 27 Feb 2015 07:44:30 -0800 (PST) Received: from [192.168.0.104] (218-164-128-147.dynamic.hinet.net. [218.164.128.147]) by mx.google.com with ESMTPSA id hu12sm4349051pdb.41.2015.02.27.07.44.27 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Fri, 27 Feb 2015 07:44:29 -0800 (PST) Message-ID: <1425051864.6032.1.camel@phoenix> Subject: [PATCH] phy: exynos5-usbdrd: Fix off-by-one valid value checking for args->args[0] From: Axel Lin To: Kishon Vijay Abraham I Cc: Vivek Gautam , "linux-kernel@vger.kernel.org" , "linux-samsung-soc@vger.kernel.org" Date: Fri, 27 Feb 2015 23:44:24 +0800 X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/phy/phy-exynos5-usbdrd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/phy-exynos5-usbdrd.c b/drivers/phy/phy-exynos5-usbdrd.c index 0437401..e2a0be7 100644 --- a/drivers/phy/phy-exynos5-usbdrd.c +++ b/drivers/phy/phy-exynos5-usbdrd.c @@ -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;