From patchwork Mon Jan 2 12:13:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaoqian Lin X-Patchwork-Id: 38113 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4131943wrt; Mon, 2 Jan 2023 04:14:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXuhwLBmoJVTeN4hWY0E2sCETbGTlqwWxkZFTYNo4QqbMgK0vQoBRbH64OTJwOIZil7YEHNP X-Received: by 2002:a17:906:819:b0:7ad:e67d:f15c with SMTP id e25-20020a170906081900b007ade67df15cmr40680193ejd.48.1672661654427; Mon, 02 Jan 2023 04:14:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672661654; cv=none; d=google.com; s=arc-20160816; b=Ow/Pq6QxmdEZ4wA3svb64B3PuquEv6rhMg2qTZx1r5Soqe5E3I4Lb5JWkjC7U6QnPr Oj4syBRAbSy6WviVOF6ZiLYaDCHCokUqU04RZrW6uol4dVZtBwhVOVI0l0AzlffTn44L LLAWWNBxhsyrDoXoPuo+8ostZ9I3HczFdkF8H+dtl9BWUeM9kmsIE0Ln2EHHvG2uFZLL Zc+jNb3pCvO4z3d87KAr23IQN88/xUpT/JhNyJjiTtQLPW2S7yQwBe+xg81U3Edk3jA4 +yuJyOJgHNLwrq7r0dkOoG7GwUmPLNy+aUi1KNUj2RF4QliYHuneMJ8WoEbNzS1nBPAU Dw+Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=zOHpSkBMQSjxH/7Gvdbef5wpYOsp0C1EIvdKSOvHDlI=; b=DILvwEjg3db4vBVVgYhI/yxvXkSbgsRksm7nOckMy9m8/46hvHQVas/fA9NgmexDMa lFEyBCbsOm7h6mlDYyTwvBF/jCLbavfAsSwwLRCGHjdGGalIPvV1YYDcK6KoSu9ocT7E 30xZrzhZ5A0NelFY1t0mA9+WdY0igUmXS1IhFhuMaTLbh2lnSshxxvuMMXyKhQng019I yrZ2+Lqr0t4HKJc/rZHIEnMUNQY8Q/9dZV7Q6+/W6/QAK/RugvHDFlpNonIoN34SRgFU f1YMkMsLiDJqKCC4CD5tLaNxwroMPzpu6V3uaxHUkqRqrRMNKhaWHxj2HPsxkspdaNGB M/aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Jc6o/DbH"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ae2-20020a17090725c200b007c103219025si22811146ejc.825.2023.01.02.04.13.50; Mon, 02 Jan 2023 04:14:14 -0800 (PST) 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=@gmail.com header.s=20210112 header.b="Jc6o/DbH"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232262AbjABMN2 (ORCPT + 99 others); Mon, 2 Jan 2023 07:13:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbjABMN1 (ORCPT ); Mon, 2 Jan 2023 07:13:27 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF3996354 for ; Mon, 2 Jan 2023 04:13:26 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id c8-20020a17090a4d0800b00225c3614161so25647797pjg.5 for ; Mon, 02 Jan 2023 04:13:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=zOHpSkBMQSjxH/7Gvdbef5wpYOsp0C1EIvdKSOvHDlI=; b=Jc6o/DbHFrkFNZavt/k9J0jeswSdRO41lcqqhOC6gql4ZX1g40pefxkv9uBgF0FbEG MppYjMAZ2jNMlv1xFugf/Q8OlztPeboXhQ0fOyT2nOHb3y2+vJCQQAZ1qXS2A3nyr20d X9PZi3RBk55/oMdT1kA+vfMxduY/PPkfXbRhxxFQJ8J+MPKPsJJfwxaau266ttSS7G8M PASQnElYWNdHQgDm7xnd7FSJnnM7RSd1D2uofd1vgfwtuW1iq73XxOjc3aBhjL45KIuI Vju2tWVd7GE/S/MND29tN2Fm+QXaesXw3SeZbGZPAgvYdHKlQe1dc/C9Xs1axKPrphty OP0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zOHpSkBMQSjxH/7Gvdbef5wpYOsp0C1EIvdKSOvHDlI=; b=rPeBckZva/ZgvxW6R0RL9N38KYQoVU8XubcnVxuVo06OuE8Gn44EzdV5/rPqCEouSn c4fA/O36+T3H/Gp8MIGZEZn4kHWuHlhbeaWUDIl+yYDvfOzda7NPVGmkRVKSuwk7zNju 996/9Ytwf67Odq5BtIMbPoq/Hf3aga/QnhuRgq/dtnDLgDOcZeqpV99ks1Xf42XoWu4j ljfvFOZE4b8C9r1VEBJOsWCi7DShSDTaOySCLWj6tSsB1pZ6N8c6zcfHO9lvZ779jcsd b/OIKbLZQeQwb8lnWmkgFoOd/7W+9qSNzYh6uCVaIOHoP2p6KDjho+GeUPbO/cvuEp+g DD3A== X-Gm-Message-State: AFqh2krxCI2LmTx11fX/sx4tcv0WM9JPLMbcJkXp7kW4rdkl9lBRsu9c YF1clck+huw8nvAV1BHqsSA= X-Received: by 2002:a17:90a:a28:b0:223:f78c:15d with SMTP id o37-20020a17090a0a2800b00223f78c015dmr44701725pjo.41.1672661606198; Mon, 02 Jan 2023 04:13:26 -0800 (PST) Received: from localhost.localdomain ([202.120.234.246]) by smtp.googlemail.com with ESMTPSA id on16-20020a17090b1d1000b0020b21019086sm33242949pjb.3.2023.01.02.04.13.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jan 2023 04:13:25 -0800 (PST) From: Miaoqian Lin To: Thomas Gleixner , Marc Zyngier , Saravana Kannan , linux-kernel@vger.kernel.org Cc: linmq006@gmail.com Subject: [PATCH] irqchip: Fix refcount leak in platform_irqchip_probe Date: Mon, 2 Jan 2023 16:13:18 +0400 Message-Id: <20230102121318.3990586-1-linmq006@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753912866958873415?= X-GMAIL-MSGID: =?utf-8?q?1753912866958873415?= of_irq_find_parent() returns a node pointer with refcount incremented, We should use of_node_put() on it when not needed anymore. Add missing of_node_put() to avoid refcount leak. Fixes: f8410e626569 ("irqchip: Add IRQCHIP_PLATFORM_DRIVER_BEGIN/END and IRQCHIP_MATCH helper macros") Signed-off-by: Miaoqian Lin --- drivers/irqchip/irqchip.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c index 3570f0a588c4..7899607fbee8 100644 --- a/drivers/irqchip/irqchip.c +++ b/drivers/irqchip/irqchip.c @@ -38,8 +38,10 @@ int platform_irqchip_probe(struct platform_device *pdev) struct device_node *par_np = of_irq_find_parent(np); of_irq_init_cb_t irq_init_cb = of_device_get_match_data(&pdev->dev); - if (!irq_init_cb) + if (!irq_init_cb) { + of_node_put(par_np); return -EINVAL; + } if (par_np == np) par_np = NULL; @@ -52,8 +54,10 @@ int platform_irqchip_probe(struct platform_device *pdev) * interrupt controller. The actual initialization callback of this * interrupt controller can check for specific domains as necessary. */ - if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) + if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY)) { + of_node_put(par_np); return -EPROBE_DEFER; + } return irq_init_cb(np, par_np); }