From patchwork Wed Jun 1 08:09:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaoqian Lin X-Patchwork-Id: 12866485 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 970AAC433EF for ; Wed, 1 Jun 2022 08:14:19 +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:References:In-Reply-To: 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: List-Owner; bh=bB+tWLQDbyRKCqlUiRWxosm8m1mket5RBco8xP/ZPbw=; b=i+230eef57sZTm ZumMXVLAsHigY/Ebw6TFk03sN331KvVBWcPUR7W148avmwUG4zQXwUKUlXaWWQrKulUWcFGhvAiNS pyZmDAwcUI48tO89mT2nv0kASLW+0fCHLj6LXlzZlRYRXQkHawr/bQSxyNpvHSGAXh1Qy0RhzjYHJ ZrV7AJtxiItXMnKDfqhQchPvF6pX3we4HtYUydPX9tld3cJQJ3ro7AS1sbNVmbWGW6rhZ6RgZQOmv rBjhhwYKbgBo0NKCPOPAZUvMzJINecVCDkXPU7S9cND8VxNFiX+dq5rlRL++DkkNs+05hsy36SlSC MT7a2f9ID0C14RChbBPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwJTJ-00EYGK-NZ; Wed, 01 Jun 2022 08:12:54 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwJSi-00EXzD-N3 for linux-arm-kernel@lists.infradead.org; Wed, 01 Jun 2022 08:12:18 +0000 Received: by mail-pl1-x632.google.com with SMTP id u18so1098248plb.3 for ; Wed, 01 Jun 2022 01:12:14 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=m+PEPLe6RgZ/co/uaiAinJBginVPw5Z9zDkizQywe5E=; b=km40SlpgsEcHZucZJOMM58TzoKmps1pvbmNm/0yqRjeCUeLKj6NHUZPPOJQisuxz+I rs9cx7BB0u1eIYLzMLL1UwKxI0Z7njWVlGW+l2GnEWZ0T3MqpChFsOrCE9YptV3SEEfa 6DKzWT5fd28uC8AzWz1kf+D9xlXYwJrVccOcbMlq3jyROjBzntUh3sOefIJsygyrUO0I HElvR9jNp87t4Sw/+ZXDV4uI8+LT+E0qJqg60uNna25YcqOMbWe42urRnYoq1YsFJ8J2 gGsPMeV37dd5rwRKh7ei0ghgmWKcFyfBshDxi2utkBoGqs747Wp1vPlo+3fqw7StAVIq 3bJQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=m+PEPLe6RgZ/co/uaiAinJBginVPw5Z9zDkizQywe5E=; b=Mgn/3UZSPYMgS7yi+498j86a+MgKyzRzSIqng0HZbHPuleu5OCOZoLP4udXV+Ensb9 EjwwLpbSRVft0ySliU8AEK//i5x56Sq84rPWUBy1EZ6Ca6HlSpEDfR5lUiea455QTKvR C2h0lWlrGieD/tyG4YDBEOy/HJ59lOpT+OSU5irGJa2jq4HbmL+HQw46MRQqOj34CWCQ HJb2wgOZclNCxMoAAQKgDttZ+w490dsUFyi5R5ympxbeCL20JyVHod+7AJwBNfkuagWP pT9g7ey5xCRFgkohMVw20BM4dadkAamliVtqh8O1Owd42GtoZWgyTTU96Io+flefbO18 Jamw== X-Gm-Message-State: AOAM530jxMm9+l2qjjNfI9DH48SpiqM9FsOjSfMdl6Qw8eihSYEcOSrK S2cO6RoYVow8vx8VRTvKco4= X-Google-Smtp-Source: ABdhPJwFrVaDOS+yHOraldAu8p/JQBxp84sZBopNyIVCcUoYq2dXh8kiVGYqtM8BBG6ywJ4n/pN6Kw== X-Received: by 2002:a17:903:124a:b0:154:c7a4:9374 with SMTP id u10-20020a170903124a00b00154c7a49374mr65595986plh.68.1654071133567; Wed, 01 Jun 2022 01:12:13 -0700 (PDT) Received: from localhost.localdomain ([202.120.234.246]) by smtp.googlemail.com with ESMTPSA id y1-20020a17090ad0c100b001e2f3831102sm792288pjw.17.2022.06.01.01.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 01:12:13 -0700 (PDT) From: Miaoqian Lin To: Hector Martin , Sven Peter , Alyssa Rosenzweig , Thomas Gleixner , Marc Zyngier , Linus Walleij , John Crispin , Bert Vermeulen , Birger Koblitz , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Miaoqian Lin Subject: [PATCH 6/6] irqchip/realtek-rtl: Fix refcount leak in map_interrupts Date: Wed, 1 Jun 2022 12:09:30 +0400 Message-Id: <20220601080930.31005-7-linmq006@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220601080930.31005-1-linmq006@gmail.com> References: <20220601080930.31005-1-linmq006@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_011216_802848_0A2E46C5 X-CRM114-Status: GOOD ( 15.86 ) 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_node_by_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. This function doesn't call of_node_put() in error path. Call of_node_put() directly after of_property_read_u32() to cover both normal path and error path. Fixes: 9f3a0f34b84a ("irqchip: Add support for Realtek RTL838x/RTL839x interrupt controller") Signed-off-by: Miaoqian Lin --- drivers/irqchip/irq-realtek-rtl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-realtek-rtl.c b/drivers/irqchip/irq-realtek-rtl.c index 50a56820c99b..56bf502d9c67 100644 --- a/drivers/irqchip/irq-realtek-rtl.c +++ b/drivers/irqchip/irq-realtek-rtl.c @@ -134,9 +134,9 @@ static int __init map_interrupts(struct device_node *node, struct irq_domain *do if (!cpu_ictl) return -EINVAL; ret = of_property_read_u32(cpu_ictl, "#interrupt-cells", &tmp); + of_node_put(cpu_ictl); if (ret || tmp != 1) return -EINVAL; - of_node_put(cpu_ictl); cpu_int = be32_to_cpup(imap + 2); if (cpu_int > 7 || cpu_int < 2)