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 7146ECCA481 for ; Tue, 28 Jun 2022 02:29:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244138AbiF1C3R (ORCPT ); Mon, 27 Jun 2022 22:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244403AbiF1CZY (ORCPT ); Mon, 27 Jun 2022 22:25:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3FDC24BC1; Mon, 27 Jun 2022 19:23:54 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 60C6D61856; Tue, 28 Jun 2022 02:23:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF3FEC36AE2; Tue, 28 Jun 2022 02:23:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656383033; bh=Wl7uIeHF1tjSZNA99qTCoGq7ATjclWNddMv1C38f5GI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AKJDBY5tl9zVcfN5hHRnrrUz6ZA1Ws/jJ/u2vQjjAMUaA4iRWXtE3mraCATVhr1zE pr7hLk2b2NAROuzG4YgW145HiiLnIvAyiVmj1xiwEQXrhXRxkPrE9Vp4wVQg5cf6y5 0Fo0stJd4XRyqJPhIT4Dde8GfEOOLXKb93zh6nR4XJPd73g62J2WttN9WyG9ycA9l6 fN7BH3O571jSHmhi50XwXE5Wb7Oo1kP0yTnptU72mYqzVThNib1uPfHkEKxlNLUS+B Zwz0IMz0nWarQWGyRKHnnWRfZ3xNWsKPOpRPbeXE//DeNAA5+FNtqJNZx+eCHUDDCZ JhdKS03l5/Ozg== 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 5.10 26/34] mips/pic32/pic32mzda: Fix refcount leak bugs Date: Mon, 27 Jun 2022 22:22:33 -0400 Message-Id: <20220628022241.595835-26-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220628022241.595835-1-sashal@kernel.org> References: <20220628022241.595835-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 f232c77ff526..0b2cd87b33d3 100644 --- a/arch/mips/pic32/pic32mzda/init.c +++ b/arch/mips/pic32/pic32mzda/init.c @@ -123,13 +123,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 7174e9abbb1b..777b515c52c8 100644 --- a/arch/mips/pic32/pic32mzda/time.c +++ b/arch/mips/pic32/pic32mzda/time.c @@ -32,6 +32,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