Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13477030ybl; Sun, 29 Dec 2019 12:50:49 -0800 (PST) X-Google-Smtp-Source: APXvYqzjz3FcK5jpjeslYa23FljdCk3F+LHJul44zQQ9+bI2+RNQarLjcxSn3bSS90xb/jc7pDM+ X-Received: by 2002:a9d:2264:: with SMTP id o91mr71399326ota.328.1577652649535; Sun, 29 Dec 2019 12:50:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652649; cv=none; d=google.com; s=arc-20160816; b=JZMkjpkQrScFd8GnBb9o0XAfLPQiwB3pXd1u8UANQs2kbjHuXj8ERwzpfSOuqFVwhm 2kSWk95hW0Ow30qcsJyk1oFO2/pHETho18zDiTV2yVer9vtshnCIdc3pyGJFnv1ZlOg8 T9oCWaV/JoOjIFyQTWOTP0luZbyCCUy9Jtt91y4PD5Xo8N03lBOGVbaCrBG7qCSw0M7s rU/P9h+XGjsPnJy1cHYTF51Jo5mWiZ+do45HoQAPnz+wSk41pEWSBhQ5siTJsCTx9Spw lebbGQjAumVypqaURWJJAa0KXA/ZidD9NpPgR5WsQ66PLqVD1NosuRECPg+bhBPnXmJk BpWg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jYoVGIJQCtOEB0IVYn08xb9miFURuARQ4qEB65ced+E=; b=WRb/NnVO7DHBhdDI2Vvj9OZEorBtSWAEzGN1w8O1pZ9YUxDOYpO2LndCCTTJuaV/YT AgCvgmok12SD5d5Ckqkglrvq27Uag/KW7SUU5tWYyUyBwEME+snpuzMan6RiH0HvhyE3 dKdQq5i6GcQu5A6VOBhBJiicWlba1kz1cDB6iop6lRyvhr9lqb3wHROKpM05kGyLDSpn rtWxyAbszqx2D9VY7Y6bzcFEga1rT3Xb3OIF8RS4bvtrjY/8NVrCq8BBsubhqupQRWtM Us4O21ltRUVM8cSJBW5bCGaU+jLqiIh4YkCXhpBvs4FD+Ju2foSIiwBoIVotqjBukmHw Hp/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WPfCmMnA; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i19si11571214oik.272.2019.12.29.12.50.38; Sun, 29 Dec 2019 12:50:49 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=WPfCmMnA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732116AbfL2SGe (ORCPT + 99 others); Sun, 29 Dec 2019 13:06:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:33524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731665AbfL2Rti (ORCPT ); Sun, 29 Dec 2019 12:49:38 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6608C206DB; Sun, 29 Dec 2019 17:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641777; bh=x2r+e3JdB2qUFXvnUBjJV4lqIGf/0i+xV8Ab4Od/bOw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WPfCmMnAczddwlyYiS38QPeiC03BPnHNuX4lD7wVQc14ReQc2uNLW+d+J7B+w0EQg ubs8Co5hP6xZND6eEtZJTa0r7hZ4p7cxh5lAFQDsuBax0osMUDnYgSOWFEGpPqu9+1 kb6/fcVumTQjhcdTAUG1wtZV223AijazH/pF1vxA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Biju Das , Geert Uytterhoeven , Wolfram Sang , Ulrich Hecht , Yoshihiro Shimoda , Kishon Vijay Abraham I , Sasha Levin Subject: [PATCH 5.4 207/434] phy: renesas: phy-rcar-gen2: Fix the array off by one warning Date: Sun, 29 Dec 2019 18:24:20 +0100 Message-Id: <20191229172715.577487969@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 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: Biju Das [ Upstream commit c9baab38fe0e28762d0d67611cbe2aef0fb3fc72 ] Fix the below smatch warning by adding variable check rather than the hardcoded value. warn: array off by one? 'data->select_value[channel_num]' Reported-by: Dan Carpenter Signed-off-by: Biju Das Reviewed-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang Reviewed-by: Ulrich Hecht Reviewed-by: Yoshihiro Shimoda Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Sasha Levin --- drivers/phy/renesas/phy-rcar-gen2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c index 2926e4937301..2e279ac0fa4d 100644 --- a/drivers/phy/renesas/phy-rcar-gen2.c +++ b/drivers/phy/renesas/phy-rcar-gen2.c @@ -71,6 +71,7 @@ struct rcar_gen2_phy_driver { struct rcar_gen2_phy_data { const struct phy_ops *gen2_phy_ops; const u32 (*select_value)[PHYS_PER_CHANNEL]; + const u32 num_channels; }; static int rcar_gen2_phy_init(struct phy *p) @@ -271,11 +272,13 @@ static const u32 usb20_select_value[][PHYS_PER_CHANNEL] = { static const struct rcar_gen2_phy_data rcar_gen2_usb_phy_data = { .gen2_phy_ops = &rcar_gen2_phy_ops, .select_value = pci_select_value, + .num_channels = ARRAY_SIZE(pci_select_value), }; static const struct rcar_gen2_phy_data rz_g1c_usb_phy_data = { .gen2_phy_ops = &rz_g1c_phy_ops, .select_value = usb20_select_value, + .num_channels = ARRAY_SIZE(usb20_select_value), }; static const struct of_device_id rcar_gen2_phy_match_table[] = { @@ -389,7 +392,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev) channel->selected_phy = -1; error = of_property_read_u32(np, "reg", &channel_num); - if (error || channel_num > 2) { + if (error || channel_num >= data->num_channels) { dev_err(dev, "Invalid \"reg\" property\n"); of_node_put(np); return error; -- 2.20.1