* [PATCH -next v2] net: ethernet: sunplus: add missing of_node_put() in spl2sw_mdio_init()
@ 2022-05-18 2:08 Yang Yingliang
2022-05-18 4:57 ` 呂芳騰
2022-05-18 13:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Yang Yingliang @ 2022-05-18 2:08 UTC (permalink / raw)
To: linux-kernel, netdev; +Cc: wellslutw, andrew, pabeni, davem, kuba
of_get_child_by_name() returns device node pointer with refcount
incremented. The refcount should be decremented before returning
from spl2sw_mdio_init().
Fixes: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
v2:
add fix tag.
---
drivers/net/ethernet/sunplus/spl2sw_mdio.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/sunplus/spl2sw_mdio.c b/drivers/net/ethernet/sunplus/spl2sw_mdio.c
index 139ac8f2685e..733ae1704269 100644
--- a/drivers/net/ethernet/sunplus/spl2sw_mdio.c
+++ b/drivers/net/ethernet/sunplus/spl2sw_mdio.c
@@ -97,8 +97,10 @@ u32 spl2sw_mdio_init(struct spl2sw_common *comm)
/* Allocate and register mdio bus. */
mii_bus = devm_mdiobus_alloc(&comm->pdev->dev);
- if (!mii_bus)
- return -ENOMEM;
+ if (!mii_bus) {
+ ret = -ENOMEM;
+ goto out;
+ }
mii_bus->name = "sunplus_mii_bus";
mii_bus->parent = &comm->pdev->dev;
@@ -110,10 +112,13 @@ u32 spl2sw_mdio_init(struct spl2sw_common *comm)
ret = of_mdiobus_register(mii_bus, mdio_np);
if (ret) {
dev_err(&comm->pdev->dev, "Failed to register mdiobus!\n");
- return ret;
+ goto out;
}
comm->mii_bus = mii_bus;
+
+out:
+ of_node_put(mdio_np);
return ret;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next v2] net: ethernet: sunplus: add missing of_node_put() in spl2sw_mdio_init()
2022-05-18 2:08 [PATCH -next v2] net: ethernet: sunplus: add missing of_node_put() in spl2sw_mdio_init() Yang Yingliang
@ 2022-05-18 4:57 ` 呂芳騰
2022-05-18 13:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: 呂芳騰 @ 2022-05-18 4:57 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-kernel, netdev, andrew, pabeni, David Miller, Jakub Kicinski
Hi Yingliang,
Thanks a lot for fixing the bug.
Reviewed-by: Wells Lu <wellslutw@gmail.com>
Best regards,
Wells
Yang Yingliang <yangyingliang@huawei.com> 於 2022年5月18日 週三 上午9:56寫道:
>
> of_get_child_by_name() returns device node pointer with refcount
> incremented. The refcount should be decremented before returning
> from spl2sw_mdio_init().
>
> Fixes: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> v2:
> add fix tag.
> ---
> drivers/net/ethernet/sunplus/spl2sw_mdio.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/sunplus/spl2sw_mdio.c b/drivers/net/ethernet/sunplus/spl2sw_mdio.c
> index 139ac8f2685e..733ae1704269 100644
> --- a/drivers/net/ethernet/sunplus/spl2sw_mdio.c
> +++ b/drivers/net/ethernet/sunplus/spl2sw_mdio.c
> @@ -97,8 +97,10 @@ u32 spl2sw_mdio_init(struct spl2sw_common *comm)
>
> /* Allocate and register mdio bus. */
> mii_bus = devm_mdiobus_alloc(&comm->pdev->dev);
> - if (!mii_bus)
> - return -ENOMEM;
> + if (!mii_bus) {
> + ret = -ENOMEM;
> + goto out;
> + }
>
> mii_bus->name = "sunplus_mii_bus";
> mii_bus->parent = &comm->pdev->dev;
> @@ -110,10 +112,13 @@ u32 spl2sw_mdio_init(struct spl2sw_common *comm)
> ret = of_mdiobus_register(mii_bus, mdio_np);
> if (ret) {
> dev_err(&comm->pdev->dev, "Failed to register mdiobus!\n");
> - return ret;
> + goto out;
> }
>
> comm->mii_bus = mii_bus;
> +
> +out:
> + of_node_put(mdio_np);
> return ret;
> }
>
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next v2] net: ethernet: sunplus: add missing of_node_put() in spl2sw_mdio_init()
2022-05-18 2:08 [PATCH -next v2] net: ethernet: sunplus: add missing of_node_put() in spl2sw_mdio_init() Yang Yingliang
2022-05-18 4:57 ` 呂芳騰
@ 2022-05-18 13:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-18 13:10 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-kernel, netdev, wellslutw, andrew, pabeni, davem, kuba
Hello:
This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Wed, 18 May 2022 10:08:12 +0800 you wrote:
> of_get_child_by_name() returns device node pointer with refcount
> incremented. The refcount should be decremented before returning
> from spl2sw_mdio_init().
>
> Fixes: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>
> [...]
Here is the summary with links:
- [-next,v2] net: ethernet: sunplus: add missing of_node_put() in spl2sw_mdio_init()
https://git.kernel.org/netdev/net-next/c/223153ea6c79
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-18 13:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-18 2:08 [PATCH -next v2] net: ethernet: sunplus: add missing of_node_put() in spl2sw_mdio_init() Yang Yingliang
2022-05-18 4:57 ` 呂芳騰
2022-05-18 13:10 ` patchwork-bot+netdevbpf
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).