Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ethernet: sunplus: add missing of_node_put() in spl2sw_mdio_init()

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>
Reviewed-by: Wells Lu <wellslutw@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Yang Yingliang and committed by
David S. Miller
223153ea 7ba106fc

+8 -3
+8 -3
drivers/net/ethernet/sunplus/spl2sw_mdio.c
··· 97 97 98 98 /* Allocate and register mdio bus. */ 99 99 mii_bus = devm_mdiobus_alloc(&comm->pdev->dev); 100 - if (!mii_bus) 101 - return -ENOMEM; 100 + if (!mii_bus) { 101 + ret = -ENOMEM; 102 + goto out; 103 + } 102 104 103 105 mii_bus->name = "sunplus_mii_bus"; 104 106 mii_bus->parent = &comm->pdev->dev; ··· 112 110 ret = of_mdiobus_register(mii_bus, mdio_np); 113 111 if (ret) { 114 112 dev_err(&comm->pdev->dev, "Failed to register mdiobus!\n"); 115 - return ret; 113 + goto out; 116 114 } 117 115 118 116 comm->mii_bus = mii_bus; 117 + 118 + out: 119 + of_node_put(mdio_np); 119 120 return ret; 120 121 } 121 122