This is a note to let you know that I've just added the patch titled net: dsa: Fix an error handling path in 'dsa_switch_parse_ports_of()' to the 5.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: net-dsa-fix-an-error-handling-path-in-dsa_switch_par.patch and it can be found in the queue-5.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 39d53a2ea597d28f9a68ec5ab2d1fc93e38e5665 Author: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx> Date: Mon Oct 18 21:59:00 2021 +0200 net: dsa: Fix an error handling path in 'dsa_switch_parse_ports_of()' [ Upstream commit ba69fd9101f20a6d05a96ab743341d4e7b1a2178 ] If we return before the end of the 'for_each_child_of_node()' iterator, the reference taken on 'port' must be released. Add the missing 'of_node_put()' calls. Fixes: 83c0afaec7b7 ("net: dsa: Add new binding implementation") Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx> Link: https://lore.kernel.org/r/15d5310d1d55ad51c1af80775865306d92432e03.1634587046.git.christophe.jaillet@xxxxxxxxxx Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 76ed5ef0e36a..28326ca34b52 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -1283,12 +1283,15 @@ static int dsa_switch_parse_ports_of(struct dsa_switch *ds, for_each_available_child_of_node(ports, port) { err = of_property_read_u32(port, "reg", ®); - if (err) + if (err) { + of_node_put(port); goto out_put_node; + } if (reg >= ds->num_ports) { dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%zu)\n", port, reg, ds->num_ports); + of_node_put(port); err = -EINVAL; goto out_put_node; } @@ -1296,8 +1299,10 @@ static int dsa_switch_parse_ports_of(struct dsa_switch *ds, dp = dsa_to_port(ds, reg); err = dsa_port_parse_of(dp, port); - if (err) + if (err) { + of_node_put(port); goto out_put_node; + } } out_put_node: