From patchwork Mon May 9 06:32:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 12843058 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 04DEAC433EF for ; Mon, 9 May 2022 06:22:56 +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=3mFgsUC7RzQTZgrUZ4ta5HeNLR7jB9PaZvq5mN06Rh4=; b=pZ+hVrigkCOVoo pgO0Rq98WjmJIAsYNmnkGYWzfw7yRrp72C2x3vkij3VWIrDIE5bCNMp4PB9XL/vFIyPgrBbVRf3Qd UGHzi4bpIFWoAG1LWcwsTtU8b0ZvYqi5hSDtXDBK8wnsE3SQ5mpqmwHgiZKG0H/DaC38/MRqlybKk kiVYhdUlGn+6R2WaA1wnZgRCQCyn5YA3weCLOaihPMj3swlZ4l9CqhOmRvPymMQr+Ar6U5eDYdstb E1nAtYanGQF14fMwBmVTVlSIdwTjQOjiNvOLGMxpjXvEGhoR27/2Rmvk7GRsHCQuxjUUP+OiCsXyV SmgTR6Z8Cxw2wWrMoSTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnwlq-00CdYR-9z; Mon, 09 May 2022 06:21:26 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnwlY-00CdRd-Qq for linux-arm-kernel@lists.infradead.org; Mon, 09 May 2022 06:21:10 +0000 Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4KxWHK4RYyz1JC02; Mon, 9 May 2022 14:19:57 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 9 May 2022 14:20:56 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 9 May 2022 14:20:55 +0800 From: Yang Yingliang To: , CC: , Subject: [PATCH 1/3] irqchip/gic-v3: add of_node_put() when finish using the device node Date: Mon, 9 May 2022 14:32:04 +0800 Message-ID: <20220509063206.3147124-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220508_232109_101938_19BD7458 X-CRM114-Status: GOOD ( 11.23 ) 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, use of_node_put() on it when done. Fixes: e3825ba1af3a ("irqchip/gic-v3: Add support for partitioned PPIs") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang --- drivers/irqchip/irq-gic-v3.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index b252d5534547..fda39adc7cd6 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -1597,6 +1597,7 @@ static int partition_domain_translate(struct irq_domain *d, ppi_idx = __gic_get_ppi_index(ppi_intid); ret = partition_translate_id(gic_data.ppi_descs[ppi_idx], of_node_to_fwnode(np)); + of_node_put(np); if (ret < 0) return ret; @@ -1906,12 +1907,15 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node) continue; cpu = of_cpu_node_to_id(cpu_node); - if (WARN_ON(cpu < 0)) + if (WARN_ON(cpu < 0)) { + of_node_put(cpu_node); continue; + } pr_cont("%pOF[%d] ", cpu_node, cpu); cpumask_set_cpu(cpu, &part->mask); + of_node_put(cpu_node); } pr_cont("}\n"); From patchwork Mon May 9 06:32:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 12843056 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 D1F54C433F5 for ; Mon, 9 May 2022 06:22:12 +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=RVMXzW2udEq5unrKDrb1HnU0H78KOEv8QKsXyj3laBI=; b=xSrmS1TiWN7Xp+ K8FDmhKHpimqVmT3sXOAoAm3y+cupAhBs2Bq2rpR32EWb4C7diCmDmmOGBS1Xln5eTQ5C3N0wS8Nr DoTLVnyJoDINRxnF5wzMcIcj//bu0OwkcsdLjbOaVCq7k5Hd4JcWdCHSbt/Jum8xhy/F66+pMxrqG tp4EQNi8Qh2+q0DmUpWILKSgfUdO8dgD4+nmUp7RuNqsNWh1sy/sa+6rBXMV+cJmMwiGuzNzTlYj3 wwsWyfcusbp2UodqkwJ5gXuPx0aGWgLU60RQONiWv9JGPzaShgMTGkreMOM5FZj64JjHkMNuJoPnY LLkvSMZBNF4OYOczisyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnwlY-00CdRe-L9; Mon, 09 May 2022 06:21:08 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnwlV-00CdQG-7V for linux-arm-kernel@lists.infradead.org; Mon, 09 May 2022 06:21:06 +0000 Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KxWBz2YsqzXdpt; Mon, 9 May 2022 14:16:11 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 9 May 2022 14:20:56 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 9 May 2022 14:20:56 +0800 From: Yang Yingliang To: , CC: , Subject: [PATCH 2/3] irqchip/gic-v3: fix missing of_node_put() in gic_populate_ppi_part() Date: Mon, 9 May 2022 14:32:05 +0800 Message-ID: <20220509063206.3147124-2-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509063206.3147124-1-yangyingliang@huawei.com> References: <20220509063206.3147124-1-yangyingliang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220508_232105_491292_674E71AA X-CRM114-Status: GOOD ( 10.25 ) 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 If kcalloc() fails, refcount of 'parts_node' should be decreased. Fixes: 52085d3f2028 ("irqchip/gic-v3: Dynamically allocate PPI partition descriptors") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang --- drivers/irqchip/irq-gic-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index fda39adc7cd6..0e23dc8bafcf 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -1866,7 +1866,7 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node) gic_data.ppi_descs = kcalloc(gic_data.ppi_nr, sizeof(*gic_data.ppi_descs), GFP_KERNEL); if (!gic_data.ppi_descs) - return; + goto out_put_node; nr_parts = of_get_child_count(parts_node); From patchwork Mon May 9 06:32:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 12843057 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 CF673C433EF for ; Mon, 9 May 2022 06:22:14 +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=P++YHBDRQt0fyqTCYjPSQZ4DDUsZSat2RO6qcCwHRPE=; b=Ykcs9joXoSb92M jPNxqAeTOjO8lTf183Xd2i4HSAGKPvGG/8qst97EjJidRqC+lfv3EL0sq2fQZ1bKQ2lcmeNPZafzg AcdGHIb/uhE8YBYZ7qKpSTpaKIGzD5mo022m4pCOIfDqzBbtEjBWx0/phx5hGzXK9lXeP6ykGWbAN NOcbcpIZJuueuzmtLSdB5NVafw/BqT2nx9cszY+V3pchiERXO1HUmk7/mwgTXEnvbO6Rn+d7edqxq xWp2X25ot1n6iWjHx6U1DiqcuvRcEqxxLxsbr1QvCpR/KXVVUcNd8sUuTByA3wmtE6fIV7hy+QIWr kDdMEq07/rl2eakj8egg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnwlh-00CdVp-Nb; Mon, 09 May 2022 06:21:17 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnwlV-00CdQF-Rl for linux-arm-kernel@lists.infradead.org; Mon, 09 May 2022 06:21:07 +0000 Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KxWBz5BNhzXdkB; Mon, 9 May 2022 14:16:11 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 9 May 2022 14:20:56 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 9 May 2022 14:20:56 +0800 From: Yang Yingliang To: , CC: , Subject: [PATCH 3/3] irqchip/gic-v3: fix possible memory leak in gic_populate_ppi_part() Date: Mon, 9 May 2022 14:32:06 +0800 Message-ID: <20220509063206.3147124-3-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509063206.3147124-1-yangyingliang@huawei.com> References: <20220509063206.3147124-1-yangyingliang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220508_232106_123717_F9A0750F X-CRM114-Status: UNSURE ( 9.81 ) X-CRM114-Notice: Please train this message. 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 'ppi_descs' should be freed in error path in gic_populate_ppi_part(). Fixes: 52085d3f2028 ("irqchip/gic-v3: Dynamically allocate PPI partition descriptors") Signed-off-by: Yang Yingliang --- drivers/irqchip/irq-gic-v3.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 0e23dc8bafcf..3264fef89360 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -1871,11 +1871,11 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node) nr_parts = of_get_child_count(parts_node); if (!nr_parts) - goto out_put_node; + goto out_free_ppi_descs; parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL); if (WARN_ON(!parts)) - goto out_put_node; + goto out_free_ppi_descs; for_each_child_of_node(parts_node, child_part) { struct partition_affinity *part; @@ -1946,6 +1946,9 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node) gic_data.ppi_descs[i] = desc; } +out_free_ppi_descs: + kfree(gic_data.ppi_descs); + gic_data.ppi_descs = NULL; out_put_node: of_node_put(parts_node); }