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

phy: hisilicon: Add of_node_put() in phy-hisi-inno-usb2

Fix following coccicheck warning:
./drivers/phy/hisilicon/phy-hisi-inno-usb2.c:138:1-23: WARNING: Function
for_each_child_of_node should have of_node_put() before break

Early exits from for_each_child_of_node should decrement the
node reference counter.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Link: https://lore.kernel.org/r/20211015080154.16016-1-wanjiabing@vivo.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Wan Jiabing and committed by
Vinod Koul
21b89120 26f71abe

+8 -2
+8 -2
drivers/phy/hisilicon/phy-hisi-inno-usb2.c
··· 140 140 struct phy *phy; 141 141 142 142 rst = of_reset_control_get_exclusive(child, NULL); 143 - if (IS_ERR(rst)) 143 + if (IS_ERR(rst)) { 144 + of_node_put(child); 144 145 return PTR_ERR(rst); 146 + } 147 + 145 148 priv->ports[i].utmi_rst = rst; 146 149 priv->ports[i].priv = priv; 147 150 148 151 phy = devm_phy_create(dev, child, &hisi_inno_phy_ops); 149 - if (IS_ERR(phy)) 152 + if (IS_ERR(phy)) { 153 + of_node_put(child); 150 154 return PTR_ERR(phy); 155 + } 151 156 152 157 phy_set_bus_width(phy, 8); 153 158 phy_set_drvdata(phy, &priv->ports[i]); ··· 160 155 161 156 if (i > INNO_PHY_PORT_NUM) { 162 157 dev_warn(dev, "Support %d ports in maximum\n", i); 158 + of_node_put(child); 163 159 break; 164 160 } 165 161 }