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

powerpc/powermac/udbg_scc: Add missing of_node_put()s in udbg_scc_init()

During the iteration of for_each_child_of_node(), we need to call
of_node_put() for the old references stored in to 'ch_def' and 'ch_a'
as their refcounters have been increased in last iteration.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220716074344.540049-1-windhl@126.com

authored by

Liang He and committed by
Michael Ellerman
2378bf14 11373c93

+6 -2
+6 -2
arch/powerpc/platforms/powermac/udbg_scc.c
··· 81 81 if (path != NULL) 82 82 stdout = of_find_node_by_path(path); 83 83 for_each_child_of_node(escc, ch) { 84 - if (ch == stdout) 84 + if (ch == stdout) { 85 + of_node_put(ch_def); 85 86 ch_def = of_node_get(ch); 86 - if (of_node_name_eq(ch, "ch-a")) 87 + } 88 + if (of_node_name_eq(ch, "ch-a")) { 89 + of_node_put(ch_a); 87 90 ch_a = of_node_get(ch); 91 + } 88 92 } 89 93 if (ch_def == NULL && !force_scc) 90 94 goto bail;