mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Amelie Delaunay <amelie.delaunay@foss.st.com>
To: Dan Carpenter <dan.carpenter@linaro.org>,
	Amelie Delaunay <amelie.delaunay@st.com>
Cc: Kishon Vijay Abraham I <kishon@kernel.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	<kernel-janitors@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Vinod Koul <vkoul@kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	<linux-phy@lists.infradead.org>,
	Fengguang Wu <fengguang.wu@intel.com>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	"Johan Hovold" <johan+linaro@kernel.org>
Subject: Re: [Linux-stm32] [PATCH] phy: stm32-usphyc: Fix off by one in probe()
Date: Tue, 9 Dec 2025 09:52:41 +0100	[thread overview]
Message-ID: <274037fa-b881-49bb-9e93-c83fefb80438@foss.st.com> (raw)
In-Reply-To: <aTfHcMJK1wFVnvEe@stanley.mountain>


On 12/9/25 07:53, Dan Carpenter wrote:
> The "index" variable is used as an index into the usbphyc->phys[] array
> which has usbphyc->nphys elements.  So if it is equal to usbphyc->nphys
> then it is one element out of bounds.  The "index" comes from the
> device tree so it's data that we trust and it's unlikely to be wrong,
> however it's obviously still worth fixing the bug.  Change the > to >=.
> 
> Fixes: 94c358da3a05 ("phy: stm32: add support for STM32 USB PHY Controller (USBPHYC)")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Hi Dan, thanks for your patch.

Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>

> ---
>   drivers/phy/st/phy-stm32-usbphyc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/st/phy-stm32-usbphyc.c b/drivers/phy/st/phy-stm32-usbphyc.c
> index 27fe92f73f33..b44afbff8616 100644
> --- a/drivers/phy/st/phy-stm32-usbphyc.c
> +++ b/drivers/phy/st/phy-stm32-usbphyc.c
> @@ -712,7 +712,7 @@ static int stm32_usbphyc_probe(struct platform_device *pdev)
>   		}
>   
>   		ret = of_property_read_u32(child, "reg", &index);
> -		if (ret || index > usbphyc->nphys) {
> +		if (ret || index >= usbphyc->nphys) {
>   			dev_err(&phy->dev, "invalid reg property: %d\n", ret);
>   			if (!ret)
>   				ret = -EINVAL;


  reply	other threads:[~2025-12-09  8:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-09  6:53 Dan Carpenter
2025-12-09  8:52 ` Amelie Delaunay [this message]
2025-12-23 17:33 ` Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=274037fa-b881-49bb-9e93-c83fefb80438@foss.st.com \
    --to=amelie.delaunay@foss.st.com \
    --cc=amelie.delaunay@st.com \
    --cc=dan.carpenter@linaro.org \
    --cc=fengguang.wu@intel.com \
    --cc=johan+linaro@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kishon@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=neil.armstrong@linaro.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®