* [PATCH] phy: ti: gmii-sel: Add a sanity check on the phy_id
@ 2025-10-17 16:04 Dan Carpenter
2025-11-19 8:34 ` Neil Armstrong
2025-11-20 17:11 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-10-17 16:04 UTC (permalink / raw)
To: Vinod Koul
Cc: Kishon Vijay Abraham I, Maxime Chevallier, Michael Walle,
Andrew Davis, linux-phy, linux-kernel, kernel-janitors
The "phy_id" comes from the device tree so it's going to be correct.
But static checkers sometimes complain when we have an upper bounds
check with no lower bounds check. Also it's a bit unusual that the
lowest valid number is 1 instead of 0 so adding a check could
potentially help someone.
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/phy/ti/phy-gmii-sel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/phy/ti/phy-gmii-sel.c b/drivers/phy/ti/phy-gmii-sel.c
index 50adabb867cb..6cfe2538d15b 100644
--- a/drivers/phy/ti/phy-gmii-sel.c
+++ b/drivers/phy/ti/phy-gmii-sel.c
@@ -341,7 +341,7 @@ static struct phy *phy_gmii_sel_of_xlate(struct device *dev,
if (priv->soc_data->features & BIT(PHY_GMII_SEL_RMII_IO_CLK_EN) &&
args->args_count < 2)
return ERR_PTR(-EINVAL);
- if (phy_id > priv->num_ports)
+ if (phy_id < 1 || phy_id > priv->num_ports)
return ERR_PTR(-EINVAL);
if (phy_id != priv->if_phys[phy_id - 1].id)
return ERR_PTR(-EINVAL);
--
2.51.0
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] phy: ti: gmii-sel: Add a sanity check on the phy_id
2025-10-17 16:04 [PATCH] phy: ti: gmii-sel: Add a sanity check on the phy_id Dan Carpenter
@ 2025-11-19 8:34 ` Neil Armstrong
2025-11-20 17:11 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Neil Armstrong @ 2025-11-19 8:34 UTC (permalink / raw)
To: Dan Carpenter, Vinod Koul
Cc: Kishon Vijay Abraham I, Maxime Chevallier, Michael Walle,
Andrew Davis, linux-phy, linux-kernel, kernel-janitors
On 10/17/25 18:04, Dan Carpenter wrote:
> The "phy_id" comes from the device tree so it's going to be correct.
> But static checkers sometimes complain when we have an upper bounds
> check with no lower bounds check. Also it's a bit unusual that the
> lowest valid number is 1 instead of 0 so adding a check could
> potentially help someone.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/phy/ti/phy-gmii-sel.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/phy/ti/phy-gmii-sel.c b/drivers/phy/ti/phy-gmii-sel.c
> index 50adabb867cb..6cfe2538d15b 100644
> --- a/drivers/phy/ti/phy-gmii-sel.c
> +++ b/drivers/phy/ti/phy-gmii-sel.c
> @@ -341,7 +341,7 @@ static struct phy *phy_gmii_sel_of_xlate(struct device *dev,
> if (priv->soc_data->features & BIT(PHY_GMII_SEL_RMII_IO_CLK_EN) &&
> args->args_count < 2)
> return ERR_PTR(-EINVAL);
> - if (phy_id > priv->num_ports)
> + if (phy_id < 1 || phy_id > priv->num_ports)
> return ERR_PTR(-EINVAL);
> if (phy_id != priv->if_phys[phy_id - 1].id)
> return ERR_PTR(-EINVAL);
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] phy: ti: gmii-sel: Add a sanity check on the phy_id
2025-10-17 16:04 [PATCH] phy: ti: gmii-sel: Add a sanity check on the phy_id Dan Carpenter
2025-11-19 8:34 ` Neil Armstrong
@ 2025-11-20 17:11 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2025-11-20 17:11 UTC (permalink / raw)
To: Dan Carpenter
Cc: Kishon Vijay Abraham I, Maxime Chevallier, Michael Walle,
Andrew Davis, linux-phy, linux-kernel, kernel-janitors
On Fri, 17 Oct 2025 19:04:23 +0300, Dan Carpenter wrote:
> The "phy_id" comes from the device tree so it's going to be correct.
> But static checkers sometimes complain when we have an upper bounds
> check with no lower bounds check. Also it's a bit unusual that the
> lowest valid number is 1 instead of 0 so adding a check could
> potentially help someone.
>
>
> [...]
Applied, thanks!
[1/1] phy: ti: gmii-sel: Add a sanity check on the phy_id
commit: 9d3daf9ca3239042c2cf473a76db2a77e6de22c6
Best regards,
--
~Vinod
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-20 17:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-17 16:04 [PATCH] phy: ti: gmii-sel: Add a sanity check on the phy_id Dan Carpenter
2025-11-19 8:34 ` Neil Armstrong
2025-11-20 17:11 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).