Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp820662rwb; Mon, 26 Sep 2022 06:20:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7+py7nV1aNPxF1V3ZREmAAIz94kPFom/qlpWd6Cg7A/MSD9D6wu75ITR8lsLOumMXTFySF X-Received: by 2002:a17:906:4ac1:b0:780:3448:ff06 with SMTP id u1-20020a1709064ac100b007803448ff06mr18319249ejt.403.1664198410392; Mon, 26 Sep 2022 06:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198410; cv=none; d=google.com; s=arc-20160816; b=UivlrBz8IPQyDRiYTap5XspQD0/vIeB+LJyvyJTiCsXtcRa0VllM8cgcqRdpFtxufX ggthyx3Czw+VcQUUT854uSbquJt8r5cVtysQOb5Z88qEL+AXMxT0Q1Q2y5ZAjDKp4Aq6 Fi4yDeU/4aWmCM4ntagSW3HcRkkjXhmuWZafU5U1nR3GYLgp9scRzh5CLtaWAmRZuNDz 5NSK11GMna35aIoV18r/Z8ioKG3TEuc6Ul5Kf1f2EtI6jYwGIElvUI9ST3dxyo9UTOri FGqtw/ghiVE0Wk/aFVxmUOR1YFlPKpmS1zOYaS/zhV5a/yWe3KKp2ADwQFLGooA+GMa0 o7UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RDaLBfXmFf1e3mbCsP8mFX2wfN+r7RIYxEOXYtlZR3I=; b=wsrSzy+lIflzNjHbhD0HW+NSqQ4cxfKMBNkceWQuY86JEuJIWMPRzo9VUhbUybMSqW wyCdnS0NjwIwmezqWJf7OOYHOJfu+mqY5xwJ3gSMXSwFCHXkMEPNroOYBGT+vM2RP6ux BBIdl1LdB+T8fKLqWxet6hWMa+EV9ikOfgPAifrOPH2Y/yNP4ODKB9IIAlyMdLhVepr8 sENGXGiUb4ez4atH/Efb1cki4GbDzY8mbd8MSxh+2byy3E7w7yN1yHuI0GTCcGFKtSqY cMHXY59QNoczMLwyH3PRp8cPqCu/mwQ2SKTfBkUDfVMtFlFq4FIUuhyqCGqV1VMt2ry0 1zPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="vjOCGC/l"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht8-20020a170907608800b0078331a3b123si685993ejc.572.2022.09.26.06.19.44; Mon, 26 Sep 2022 06:20:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="vjOCGC/l"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235146AbiIZKSM (ORCPT + 99 others); Mon, 26 Sep 2022 06:18:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234891AbiIZKRY (ORCPT ); Mon, 26 Sep 2022 06:17:24 -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 45B7836DF8; Mon, 26 Sep 2022 03:15:04 -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 101D5B80925; Mon, 26 Sep 2022 10:15:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6797FC433C1; Mon, 26 Sep 2022 10:14:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664187299; bh=qKqAQRD6cxz9W/PwVbpSTLflZheubG7vtgJbTS+PnZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vjOCGC/lTtLhVZJDmT6mN1hB4fEIFt+qPy/lkXkaRYtBP9kJXI2yisDR6BqkvxIj0 07V8opfoY3NEfltmWK9eM4H4F+J1G93M7uvmhZ/54JBkRy+uprv0d99UzlAlQvWf9R 4s56HroC5aGTCNTTfm2zOb7zqLnWFwRHzmnO/540= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liang He , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 4.9 10/30] mips/pic32/pic32mzda: Fix refcount leak bugs Date: Mon, 26 Sep 2022 12:11:41 +0200 Message-Id: <20220926100736.537955607@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100736.153157100@linuxfoundation.org> References: <20220926100736.153157100@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 406c6c5cec29..f8985d4573e6 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 62a0a78b6c64..bfafe241c1b5 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