phy: ti: gmii-sel: check of_get_address() for failure
Subsystems (2)
PATCH 1/1 phy: ti: gmii-sel: check of_get_address() for failure
Smatch complains that if of_get_address() returns NULL, then "size" isn't initialized. Also it would lead to an Oops.
Fixes 7f78322cdd67 ("phy: ti: gmii-sel: retrieve ports number and base offset from dt")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/phy/ti/phy-gmii-sel.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/ti/phy-gmii-sel.c +2 -0
@@ -320,6 +320,8 @@ static int phy_gmii_sel_init_ports(struct phy_gmii_sel_priv *priv)u64 size; offset =of_get_address (dev->of_node,0 , &size,NULL ); +if (!offset) +return -EINVAL ; priv->num_ports = size /sizeof (u32);if (!priv->num_ports)return -EINVAL ;
Signature · 7 lines
2.20.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Quoted 8 lines · Dan Carpenter
Smatch complains that if
of_get_address()returns NULL, then "size" isn't initialized. Also it would lead to an Oops.Fixes 7f78322cdd67 ("phy: ti: gmii-sel: retrieve ports number and base offset from dt")Signed-off-by Dan Carpenter <[email protected]>--- drivers/phy/ti/phy-gmii-sel.c | 2 ++ 1 file changed, 2 insertions(+)
Thank you.
Reviewed-by Grygorii Strashko <[email protected]>
Quoted 15 lines
drivers/phy/ti/phy-gmii-sel.c +2
-0@@ -320,6 +320,8 @@ static int phy_gmii_sel_init_ports(struct phy_gmii_sel_priv *priv)u64 size; offset =of_get_address (dev->of_node,0 , &size,NULL ); +if (!offset) +return -EINVAL ; priv->num_ports = size /sizeof (u32);if (!priv->num_ports)return -EINVAL ;
Signature · 7 lines
Best regards, grygorii -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Quoted 2 lines · Dan Carpenter
Smatch complains that if
of_get_address()returns NULL, then "size" isn't initialized. Also it would lead to an Oops.
Applied, thanks
Quoted 22 lines
Fixes 7f78322cdd67 ("phy: ti: gmii-sel: retrieve ports number and base offset from dt")Signed-off-by Dan Carpenter <[email protected]>--- drivers/phy/ti/phy-gmii-sel.c | 2 ++ 1 file changed, 2 insertions(+)drivers/phy/ti/phy-gmii-sel.c +2
-0@@ -320,6 +320,8 @@ static int phy_gmii_sel_init_ports(struct phy_gmii_sel_priv *priv)u64 size; offset =of_get_address (dev->of_node,0 , &size,NULL ); +if (!offset) +return -EINVAL ; priv->num_ports = size /sizeof (u32);if (!priv->num_ports)return -EINVAL ;Signature · 1 line
2.20.1
Signature · 6 lines
~Vinod -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy