* [PATCH] phy: ti: gmii-sel: check of_get_address() for failure
@ 2021-09-14 11:00 Dan Carpenter
2021-09-15 9:27 ` Grygorii Strashko
2021-10-20 17:27 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-09-14 11:00 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Grygorii Strashko
Cc: Vinod Koul, linux-phy, kernel-janitors
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 <dan.carpenter@oracle.com>
---
drivers/phy/ti/phy-gmii-sel.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/phy/ti/phy-gmii-sel.c b/drivers/phy/ti/phy-gmii-sel.c
index 5fd2e8a08bfc..d0ab69750c6b 100644
--- a/drivers/phy/ti/phy-gmii-sel.c
+++ b/drivers/phy/ti/phy-gmii-sel.c
@@ -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;
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] phy: ti: gmii-sel: check of_get_address() for failure
2021-09-14 11:00 [PATCH] phy: ti: gmii-sel: check of_get_address() for failure Dan Carpenter
@ 2021-09-15 9:27 ` Grygorii Strashko
2021-10-20 17:27 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Grygorii Strashko @ 2021-09-15 9:27 UTC (permalink / raw)
To: Dan Carpenter, Kishon Vijay Abraham I
Cc: Vinod Koul, linux-phy, kernel-janitors
On 14/09/2021 14:00, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>
> ---
> drivers/phy/ti/phy-gmii-sel.c | 2 ++
> 1 file changed, 2 insertions(+)
Thank you.
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
>
> diff --git a/drivers/phy/ti/phy-gmii-sel.c b/drivers/phy/ti/phy-gmii-sel.c
> index 5fd2e8a08bfc..d0ab69750c6b 100644
> --- a/drivers/phy/ti/phy-gmii-sel.c
> +++ b/drivers/phy/ti/phy-gmii-sel.c
> @@ -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;
>
--
Best regards,
grygorii
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] phy: ti: gmii-sel: check of_get_address() for failure
2021-09-14 11:00 [PATCH] phy: ti: gmii-sel: check of_get_address() for failure Dan Carpenter
2021-09-15 9:27 ` Grygorii Strashko
@ 2021-10-20 17:27 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2021-10-20 17:27 UTC (permalink / raw)
To: Dan Carpenter
Cc: Kishon Vijay Abraham I, Grygorii Strashko, linux-phy, kernel-janitors
On 14-09-21, 14:00, Dan Carpenter wrote:
> Smatch complains that if of_get_address() returns NULL, then "size"
> isn't initialized. Also it would lead to an Oops.
Applied, thanks
>
> Fixes: 7f78322cdd67 ("phy: ti: gmii-sel: retrieve ports number and base offset from dt")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/phy/ti/phy-gmii-sel.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/phy/ti/phy-gmii-sel.c b/drivers/phy/ti/phy-gmii-sel.c
> index 5fd2e8a08bfc..d0ab69750c6b 100644
> --- a/drivers/phy/ti/phy-gmii-sel.c
> +++ b/drivers/phy/ti/phy-gmii-sel.c
> @@ -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;
> --
> 2.20.1
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-20 17:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 11:00 [PATCH] phy: ti: gmii-sel: check of_get_address() for failure Dan Carpenter
2021-09-15 9:27 ` Grygorii Strashko
2021-10-20 17:27 ` 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).