diff mbox series

[-next] net: ethernet: sunplus: add missing of_node_put() in spl2sw_mdio_init()

Message ID 20220516143734.1598316-1-yangyingliang@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [-next] net: ethernet: sunplus: add missing of_node_put() in spl2sw_mdio_init() | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: edumazet@google.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Yang Yingliang May 16, 2022, 2:37 p.m. UTC
of_get_child_by_name() returns device node pointer with refcount
incremented. The refcount should be decremented before returning
from spl2sw_mdio_init().

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/net/ethernet/sunplus/spl2sw_mdio.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Jakub Kicinski May 18, 2022, 12:47 a.m. UTC | #1
On Mon, 16 May 2022 22:37:34 +0800 Yang Yingliang wrote:
> of_get_child_by_name() returns device node pointer with refcount
> incremented. The refcount should be decremented before returning
> from spl2sw_mdio_init().
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Please add a Fixes tag, even if the change in question is only in
linux-next.

Wells Lu, the expectation for networking maintainers is that you will
review patches for your driver without 24, max 48 hours (not counting
weekends). Please respond with feedback or Acked-by / Reviewed-by tags
now that your driver has been merged. Thanks.
diff mbox series

Patch

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;
 }