From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============1984317927040179556==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] dsa: fix for_each_child.cocci warnings Date: Sun, 11 Jul 2021 22:27:55 +0800 Message-ID: <20210711142755.GA19709@c3b7951da422> In-Reply-To: <202107112258.7gxxyYm4-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============1984317927040179556== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Alexander Lobakin CC: Vladimir Oltean CC: Florian Fainelli CC: Woojung Huh CC: UNGLinuxDriver(a)microchip.com CC: Andrew Lunn CC: Vivien Didelot CC: Jakub Kicinski CC: netdev(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/net/dsa/microchip/ksz_common.c:418:3-35: WARNING: Function "for_eac= h_available_child_of_node" should have of_node_put() before return around l= ine 423. Semantic patch information: False positives can be due to function calls within the for_each loop that may encapsulate an of_node_put. Generated by: scripts/coccinelle/iterators/for_each_child.cocci CC: Alexander Lobakin Reported-by: kernel test robot Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git = master head: de5540965853e514a85d3b775e9049deb85a2ff3 commit: 227d72063fccb2d19b30fb4197fba478514f7d83 dsa: simplify Kconfig symb= ols and dependencies :::::: branch date: 15 hours ago :::::: commit date: 4 months ago Please take the patch only if it's a positive warning. Thanks! ksz_common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -419,8 +419,10 @@ int ksz_switch_register(struct ksz_devic if (of_property_read_u32(port, "reg", &port_num)) continue; - if (!(dev->port_mask & BIT(port_num))) + if (!(dev->port_mask & BIT(port_num))) { + of_node_put(port); return -EINVAL; + } of_get_phy_mode(port, &dev->ports[port_num].interface); } --===============1984317927040179556==--