Skip to content

Commit 9d3daf9

Browse files
Dan Carpentervinodkoul
authored andcommitted
phy: ti: gmii-sel: Add a sanity check on the phy_id
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> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://patch.msgid.link/aPJpB-QI8FMpFGOk@stanley.mountain Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 1797c66 commit 9d3daf9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/phy/ti/phy-gmii-sel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static struct phy *phy_gmii_sel_of_xlate(struct device *dev,
341341
if (priv->soc_data->features & BIT(PHY_GMII_SEL_RMII_IO_CLK_EN) &&
342342
args->args_count < 2)
343343
return ERR_PTR(-EINVAL);
344-
if (phy_id > priv->num_ports)
344+
if (phy_id < 1 || phy_id > priv->num_ports)
345345
return ERR_PTR(-EINVAL);
346346
if (phy_id != priv->if_phys[phy_id - 1].id)
347347
return ERR_PTR(-EINVAL);

0 commit comments

Comments
 (0)