From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BC66C00140 for ; Tue, 2 Aug 2022 04:53:24 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4LxjLC0zrFz3c72 for ; Tue, 2 Aug 2022 14:53:23 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.crashing.org (client-ip=63.228.1.57; helo=gate.crashing.org; envelope-from=benh@kernel.crashing.org; receiver=) Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lists.ozlabs.org (Postfix) with ESMTP id 4LxjKm4ByJz2xHB for ; Tue, 2 Aug 2022 14:52:59 +1000 (AEST) Received: from ip6-localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 2724oWWl004209; Mon, 1 Aug 2022 23:50:33 -0500 Message-ID: <9fb802d118eca207ffb887201b7b12970b054a27.camel@kernel.crashing.org> Subject: Re: [PATCH] powerpc/powermac/udbg_scc: Fix refcount leak bug in udbg_scc_init() From: Benjamin Herrenschmidt To: Liang He , mpe@ellerman.id.au, paulus@samba.org, linuxppc-dev@lists.ozlabs.org Date: Tue, 02 Aug 2022 14:50:32 +1000 In-Reply-To: <20220716074344.540049-1-windhl@126.com> References: <20220716074344.540049-1-windhl@126.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Sat, 2022-07-16 at 15:43 +0800, Liang He wrote: > 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. None of these matter since those nodes are never *ever* released and those machines don't use dynamic node allocation but ... > Fixes: 51d3082fe6e5 ("[PATCH] powerpc: Unify udbg (#2)") > Signed-off-by: Liang He > --- > arch/powerpc/platforms/powermac/udbg_scc.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/platforms/powermac/udbg_scc.c > b/arch/powerpc/platforms/powermac/udbg_scc.c > index 734df5a32f99..1b7c39e841ee 100644 > --- a/arch/powerpc/platforms/powermac/udbg_scc.c > +++ b/arch/powerpc/platforms/powermac/udbg_scc.c > @@ -81,10 +81,14 @@ void __init udbg_scc_init(int force_scc) > if (path != NULL) > stdout = of_find_node_by_path(path); > for_each_child_of_node(escc, ch) { > - if (ch == stdout) > + if (ch == stdout) { > + of_node_put(ch_def); > ch_def = of_node_get(ch); > - if (of_node_name_eq(ch, "ch-a")) > + } > + if (of_node_name_eq(ch, "ch-a")) { > + of_node_put(ch_a); > ch_a = of_node_get(ch); > + } > } > if (ch_def == NULL && !force_scc) > goto bail;