]> git.hungrycats.org Git - linux/commit
spmi: pmic-arb: fix return path in for_each_available_child_of_node()
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Sat, 9 Nov 2024 00:28:26 +0000 (16:28 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 Dec 2024 09:41:03 +0000 (10:41 +0100)
commit43cc7939f5e62b35774d2a864db121e03f85a2fc
tree6db05073d44869bafa52192b3e08609e95ffdf9d
parentd34bf994bb973db1d142376e555e093c3146f730
spmi: pmic-arb: fix return path in for_each_available_child_of_node()

commit 77adf4b1f3e1fdb319f7ee515e5924bb77df3916 upstream.

This loop requires explicit calls to of_node_put() upon early exits
(break, goto, return) to decrement the child refcounter and avoid memory
leaks if the child is not required out of the loop.

A more robust solution is using the scoped variant of the macro, which
automatically calls of_node_put() when the child goes out of scope.

Cc: stable@vger.kernel.org
Fixes: 979987371739 ("spmi: pmic-arb: Add multi bus support")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20241001-spmi-pmic-arb-scoped-v1-1-5872bab34ed6@gmail.com
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20241109002829.160973-2-sboyd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/spmi/spmi-pmic-arb.c