From patchwork Thu May 12 08:10:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaoqian Lin X-Patchwork-Id: 12847294 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 370F9C433F5 for ; Thu, 12 May 2022 08:11:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=H3NiMY9ekokT5LmVz7DWzy1+wfOmjvmsH8/aCAd/fZk=; b=4yA1qvjDgrmiCS SKMkeCAJ7Gdzi3nIJOW/6+rzkteg4SaXNfJNJ/vR+V81eHvzb+dNMK8G7O9/QQFk+T76+Xhhc9IAR iPTcOlGc1HQ9yeQKRx5R5jcg2zMmt3fCYJXLEo99EWZNxbfn+V/sApkuwNcKzQFFb6IpX2sN/vmTJ wIv45awN01H6jAQ/G4i3gWwET6HJXhcnqTK40XQcJo9NHqja63Cr8dC+q6xqUo+/MVD326XNqYN9e gFB3rKGUiOWw7OaV62wQiSAmFWD3UY8KqplypsFgT4YguXD1w+vGdUNTpM1Mnr5iMT5pmBvJYJ/I1 FWf5V8nAr0mtlFxasiFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1np3uI-00AsfD-Iu; Thu, 12 May 2022 08:10:46 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1np3uF-00AseD-Ay for linux-arm-kernel@lists.infradead.org; Thu, 12 May 2022 08:10:44 +0000 Received: by mail-pj1-x1031.google.com with SMTP id cx11-20020a17090afd8b00b001d9fe5965b3so7132208pjb.3 for ; Thu, 12 May 2022 01:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fYxJzIlygzVtOu994zXNVLK64i/sa8H3L0sgERB2T50=; b=VRctKcDXv9xMu5JW5m0qsoBjvlr3ctTf+JhmvcxaOLPYGBFDbyPQTnhV8u6eCg0Mqu 6qQkxwkHtaZTTNk082+S62OFf9aslJZ8cS6p4tgPjg0b9poI3dONCo9PTXjzF7a1A1Mf 7e7oUKAomP3KFVPzcZRTWzSAFWaabh+xmnKYSF6f2Kvu53YJTzYJUpTnZrMVu0YU7jAN 80umIx2HFePbizdbEd9F2ldCh81iII5aJLrdwyZPDAFbJkDI6p/tkfJBxBbV1GjTozL5 tlGx9NyS8LtN7qltNMpZlcR9RKZ9Ya94NrIWmPc1Bo8Y4ROSmV6B2RFdWee4ItFk8Ymp BlhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fYxJzIlygzVtOu994zXNVLK64i/sa8H3L0sgERB2T50=; b=j2EMyaHP7TLJzOntGXL0QvHRRZZBGmqEDQB6j/uskFCXSTJiKPoclg2iq+ddqG5v9P r1y94UpuRdn/WOdlCLJ0x4yPMYgO3bBBq1lO/bbfaECgzAKkFymg55AJf9t1cArc3J0h CD7FkhPcM4qNO6kTjDHvpNfEfu0HdU1JatGlfjmmeb+OClIiTJnSOud/cKzR2Im8ha0R lBYgDiREkMn0J9bb668XmNiBUUumbqzgW2LYS796m2xhRUtWFbu0b7TYqMHQGNRK/wpA VN3mjRk/5mEot4FvnhJEFjnker2UFwtF20hchzb/tTPoJK7jBxJ7TgVMS2NmOg2QJlrJ 2RNA== X-Gm-Message-State: AOAM5332v/EvFhLyswuYMf9JvqkSjMrCMJwdh7hrk6bJ3v5/4Y33S7Er YUbjQkXIK4J/xL7zh+rkX9U= X-Google-Smtp-Source: ABdhPJxWOE6dWlMK0mfC4ikh55aYQppXtqMkDNX4jcU8cX+Jt/bJ6LBoJnZyFghyC//BgxhUM1KKXA== X-Received: by 2002:a17:90a:e38c:b0:1de:b43f:f969 with SMTP id b12-20020a17090ae38c00b001deb43ff969mr9691861pjz.126.1652343040255; Thu, 12 May 2022 01:10:40 -0700 (PDT) Received: from localhost.localdomain ([202.120.234.246]) by smtp.googlemail.com with ESMTPSA id 10-20020a17090a174a00b001d5f22845bdsm1737745pjm.1.2022.05.12.01.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 01:10:39 -0700 (PDT) From: Miaoqian Lin To: Wei Xu , Russell King , Haojian Zhuang , Nicolas Pitre , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: linmq006@gmail.com Subject: [PATCH] ARM: hisi: Fix refcount leak in hip04_smp_init Date: Thu, 12 May 2022 12:10:31 +0400 Message-Id: <20220512081031.24301-1-linmq006@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220512_011043_430285_4049CF07 X-CRM114-Status: GOOD ( 13.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org of_find_compatible_node() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak. Fixes: 9cdc99919a95 ("ARM: hisi: enable MCPM implementation") Signed-off-by: Miaoqian Lin --- arch/arm/mach-hisi/platmcpm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-hisi/platmcpm.c b/arch/arm/mach-hisi/platmcpm.c index 258586e31333..e9b5d63ecf4c 100644 --- a/arch/arm/mach-hisi/platmcpm.c +++ b/arch/arm/mach-hisi/platmcpm.c @@ -274,6 +274,7 @@ static int __init hip04_smp_init(void) goto err; ret = of_property_read_u32_array(np, "boot-method", &hip04_boot_method[0], 4); + of_node_put(np); if (ret) goto err; @@ -283,11 +284,11 @@ static int __init hip04_smp_init(void) goto err; np_fab = of_find_compatible_node(NULL, NULL, "hisilicon,hip04-fabric"); if (!np_fab) - goto err; + goto err_put_sctl; ret = memblock_reserve(hip04_boot_method[0], hip04_boot_method[1]); if (ret) - goto err; + goto err_put_fab; relocation = ioremap(hip04_boot_method[2], hip04_boot_method[3]); if (!relocation) { @@ -329,6 +330,8 @@ static int __init hip04_smp_init(void) writel_relaxed(__pa_symbol(secondary_startup), relocation + 8); writel_relaxed(0, relocation + 12); iounmap(relocation); + of_node_put(np_fab); + of_node_put(np_sctl); smp_set_ops(&hip04_smp_ops); return ret; @@ -340,6 +343,10 @@ static int __init hip04_smp_init(void) iounmap(relocation); err_reloc: memblock_phys_free(hip04_boot_method[0], hip04_boot_method[1]); +err_put_fab: + of_node_put(np_fab); +err_put_sctl: + of_node_put(np_sctl); err: return ret; }