Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4116907imm; Mon, 8 Oct 2018 15:24:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV634RjbRsqsjU6K58gdwSgYrPJ+3uV3xG5JaKAAYN066GExIbfivSwpQc/xl+HGIHn4vcm/V X-Received: by 2002:a17:902:b907:: with SMTP id bf7-v6mr16003178plb.259.1539037499110; Mon, 08 Oct 2018 15:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539037499; cv=none; d=google.com; s=arc-20160816; b=HOO3bbYq16G7DVzNvfOktP26ppa3z+saCyQ/wLJbaJdwEEFzZzxjlIALXKp4N+/odJ S5Qt2U69zwiYvWmW8kMegnP2eyNPR7YaQBeY+36BndN734MnRLjBDWb/u3DlH1HkUYAj Uv9TxKnCnXShE1qYHIhWHKk8N1mN0qt4PmAmXUJxpy8k8ggHDyIT6mldGQ4kMwnbiLpY p1BSLVkS9ayPrwoLKNUp/f0gSdVu5K6XeRuA5Bz+b9jDRowQGle06fmvC29I3XD2QMhn u7PwvdMeq+SDG8Ctnsefk3rR0auxbw69sluLHKT7Q7qy92SA2y/heToh1VJxmEEBJgXU gTBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Tq2UBRJ5IA5gH4eyTXjmt8Bj0kvqtfwXBS7BhZ3pWVA=; b=osMpLZ30nZLVES0ntNeaGGh+LAmQ4wwcO1ZLJ99lw8UCbRqbG+EpANNl+nAS6Rfsf2 FiPqA60nxUYVzVpfrXuskOVxxakr4kPTvuQ2knOHcXlx+GLGWL5h6VsJiiPPiuJREiZL 6scupo4mIDhlnc9r+hNVqcQ8D7dqT4WXwloE99wa4ISa8OLayA7JlIkkszu1IxdWnT69 TXUhs/PsHX0qIoDxy3ow0u5Vk6LJ26PLKtJA/pR5W8MqYQ8q8OR/Am6FMhONXp4CFX3Z srLI5w+Ujkn1rZTt5b5S9Ah6xZyIUxXly77SmavWlT8eGIuu6dvm+fCZ3hdyk8rLaQNS KMiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5-v6si17059481pgj.275.2018.10.08.15.24.44; Mon, 08 Oct 2018 15:24:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726415AbeJIFiR (ORCPT + 99 others); Tue, 9 Oct 2018 01:38:17 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:40535 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725783AbeJIFiR (ORCPT ); Tue, 9 Oct 2018 01:38:17 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1g9dwn-00053l-W8; Mon, 08 Oct 2018 22:24:18 +0000 From: Colin King To: Kishon Vijay Abraham I , Shawn Guo , Jiancheng Xue Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] phy: inno-usb2-phy: fix off-by-one comparison on port number Date: Mon, 8 Oct 2018 23:24:17 +0100 Message-Id: <20181008222417.11739-1-colin.king@canonical.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King Currently the range check on the port index is off-by-one and a potential out of bounds write can occur on priv->ports[i]. Fix this by checking the maximum port using >= INNO_PHY_PORT_NUM rather than > INNO_PHY_PORT_NUM. Detected by CoverityScan, CID#1466118 ("Out-of-bounds write") Fixes: ba8b0ee81fbb ("phy: add inno-usb2-phy driver for hi3798cv200 SoC") Signed-off-by: Colin Ian King --- drivers/phy/hisilicon/phy-hisi-inno-usb2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/hisilicon/phy-hisi-inno-usb2.c b/drivers/phy/hisilicon/phy-hisi-inno-usb2.c index 524381249a2b..b51e19402ab0 100644 --- a/drivers/phy/hisilicon/phy-hisi-inno-usb2.c +++ b/drivers/phy/hisilicon/phy-hisi-inno-usb2.c @@ -167,7 +167,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); break; } -- 2.17.1