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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62537ECAAD8 for ; Wed, 14 Sep 2022 09:17:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231516AbiINJR2 (ORCPT ); Wed, 14 Sep 2022 05:17:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231491AbiINJP1 (ORCPT ); Wed, 14 Sep 2022 05:15:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B59F786EE; Wed, 14 Sep 2022 02:07:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E9AEEB8172F; Wed, 14 Sep 2022 09:06:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8D9DC433D6; Wed, 14 Sep 2022 09:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663146389; bh=Psu9mgVlpAID1f3fUJXWwzfUSz7bDIgl4t/Jad5io5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aLyY03FpoFGyfp17VuFZfW+r3KuvdwZyc3f7BaCPwexVShIv8iIJ+Eu51LfgAbE20 +qxYqXDXD1tkXjbZEt8Lm/8N30qU0YlE5qBpbUE52TJXHR9NX6xxMegHyCVU5/6CO+ FcLRQUHzmE65Wjkz9eHy5mUuZmfIc9RrwtSBdj9G3DesFSDzc/51tkgC1T4ZivnlB6 OuwfBdt1jPxxGLPDBNsCCbeswgrvBgVI0mj+47arrx6IP/nKDkoSv0buzcBuPNMINV E+MvAXTf2etGFlxGyDs9RK39WHgbcin0yLqREvuP4OwMhNDlFYooIWtnrYNBBMRDfe Pij4m1tX3W1Aw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Liang He , Thomas Bogendoerfer , Sasha Levin , yangtiezhu@loongson.cn, linux-mips@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 11/13] mips/pic32/pic32mzda: Fix refcount leak bugs Date: Wed, 14 Sep 2022 05:05:38 -0400 Message-Id: <20220914090540.471725-11-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220914090540.471725-1-sashal@kernel.org> References: <20220914090540.471725-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liang He [ Upstream commit eb9e9bc4fa5fb489c92ec588b3fb35f042ba6d86 ] of_find_matching_node(), of_find_compatible_node() and of_find_node_by_path() will return node pointers with refcout incremented. We should call of_node_put() when they are not used anymore. Signed-off-by: Liang He Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- arch/mips/pic32/pic32mzda/init.c | 7 ++++++- arch/mips/pic32/pic32mzda/time.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/mips/pic32/pic32mzda/init.c b/arch/mips/pic32/pic32mzda/init.c index 406c6c5cec29b..f8985d4573e69 100644 --- a/arch/mips/pic32/pic32mzda/init.c +++ b/arch/mips/pic32/pic32mzda/init.c @@ -131,13 +131,18 @@ static int __init pic32_of_prepare_platform_data(struct of_dev_auxdata *lookup) np = of_find_compatible_node(NULL, NULL, lookup->compatible); if (np) { lookup->name = (char *)np->name; - if (lookup->phys_addr) + if (lookup->phys_addr) { + of_node_put(np); continue; + } if (!of_address_to_resource(np, 0, &res)) lookup->phys_addr = res.start; + of_node_put(np); } } + of_node_put(root); + return 0; } diff --git a/arch/mips/pic32/pic32mzda/time.c b/arch/mips/pic32/pic32mzda/time.c index 62a0a78b6c644..bfafe241c1b5f 100644 --- a/arch/mips/pic32/pic32mzda/time.c +++ b/arch/mips/pic32/pic32mzda/time.c @@ -40,6 +40,9 @@ static unsigned int pic32_xlate_core_timer_irq(void) goto default_map; irq = irq_of_parse_and_map(node, 0); + + of_node_put(node); + if (!irq) goto default_map; -- 2.35.1