From patchwork Sat Apr 13 06:40:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guanrui Huang X-Patchwork-Id: 13628643 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 2BB62C4345F for ; Sat, 13 Apr 2024 06:41:22 +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=T2vpQNdo2lPHvOGS/b2jRBwMcUOZmgjSbFqLANU/Yp0=; b=YVhQhXwgcpM0gJ ssq+19IX9+60NEFTv+NQl576CdVoshrB8xefdjKbPakXmW0cLbCsuJFOsoD/dtsoWfynZB1RaS1O+ dRmQ3KmWj9gyqXTczE7pTiKe7pYL/LIi/KffvnPwNdJodlwg2hFEQGYMQU+GPG2amMH8qWbMB3lEY cSFYmnHIPGxElCH1xLqTovOK/JnPpkqLBdUK2xETdg+EVcf940//HmuH9pUB9co87EfRI+Wuy1+oL ZrrrAueWYGiwz2FmuoXcaurfdtxAOGn5HSODd9vKI4UROPzEvvPHwnipy/UaS3v6caRGL/49Dz+U7 +d0Bu2/74sEOsy6gZXOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvX4Z-00000002YRB-3WEy; Sat, 13 Apr 2024 06:41:11 +0000 Received: from out30-113.freemail.mail.aliyun.com ([115.124.30.113]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvX4Q-00000002YPt-2aAH for linux-arm-kernel@lists.infradead.org; Sat, 13 Apr 2024 06:41:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1712990456; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=/OZ68aDj4lKRSYMfEx7Rvi/TenxwyTAvkYzYhYxFPtE=; b=oYNMfk70X85p3tvv5rMXm5kaqq16uUJqwQ5XnJ9qXlfp8Svief65/0dXj2oMg/gYZR1kKbbhXiKMszQKqfW8QJDNuYPwXulp171tovJyahINY48TPoVytf0l8rCgzTJIfEjVuBliTwHL4hoMaiTeypiwkGtsax3x8ZIzb0t243k= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R321e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=guanrui.huang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0W4Q.spW_1712990452; Received: from localhost(mailfrom:guanrui.huang@linux.alibaba.com fp:SMTPD_---0W4Q.spW_1712990452) by smtp.aliyun-inc.com; Sat, 13 Apr 2024 14:40:53 +0800 From: Guanrui Huang To: maz@kernel.org Cc: yuzenghui@huawei.com, shannon.zhao@linux.alibaba.com, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Guanrui Huang Subject: [PATCH v4 1/2] irqchip/gic-v3-its: Fix double free on error Date: Sat, 13 Apr 2024 14:40:50 +0800 Message-Id: <20240413064051.31315-1-guanrui.huang@linux.alibaba.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_234103_170268_235810A7 X-CRM114-Status: UNSURE ( 8.23 ) 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 In its_vpe_irq_domain_alloc, when its_vpe_init() returns an error with i > 0, its_vpe_irq_domain_free may free bitmap and vprop_page, and then there is a double free in its_vpe_irq_domain_alloc. Fix it by calling its_vpe_irq_domain_free directly, bitmap and vprop_page will be freed in this function. Signed-off-by: Guanrui Huang Reviewed-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3-its.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index fca888b36680..2305f6b524a9 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -4561,13 +4561,8 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq irqd_set_resend_when_in_progress(irq_get_irq_data(virq + i)); } - if (err) { - if (i > 0) - its_vpe_irq_domain_free(domain, virq, i); - - its_lpi_free(bitmap, base, nr_ids); - its_free_prop_table(vprop_page); - } + if (err) + its_vpe_irq_domain_free(domain, virq, i); return err; } From patchwork Sat Apr 13 06:40:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guanrui Huang X-Patchwork-Id: 13628644 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 E58C6C4345F for ; Sat, 13 Apr 2024 06:41:25 +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=dQYcoK8/s91Q+4lOkEw7ztORDMABbY+bagqIWrbMtWc=; b=PwI3pUteywwzTP O6171lKfySOCIaMLm66T+vgtYztW5dvifEn11nOFrO+FDtCGtDHdzDBT9S7VNBY4XIezuTvHPJ7IM 8bI0VcLC3Ahy5uMeepXdkIelProDAgMrWokHqp1Z0VR4wSHo2AzKnbxghPtXThDdeRN4nJ9MhYsRM MM8Zn8FaYQMaI21VawS1mAnsuOPC/++zvqNvhPSudrAvBGhrlXGzS2gQc+iAFhT0ikI89w2soy0y6 YsXROmCyNfKNK3qZRMVXY0DOYZGkoeEee5hnSczZyKFBfp3MDDH30Vdf04WD5THgwIq+2dAisu7XG DZbMgBp0e6RIQ3ayDuLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvX4e-00000002YRy-2Ukj; Sat, 13 Apr 2024 06:41:16 +0000 Received: from out30-101.freemail.mail.aliyun.com ([115.124.30.101]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvX4W-00000002YQV-0fCP for linux-arm-kernel@lists.infradead.org; Sat, 13 Apr 2024 06:41:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1712990465; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=QINZpNy4fyNIwPgJV/+sxBA/hpwDqIxyGlkaaIbfV+8=; b=gUKiSWnYwhpFRz2AjpIS7RxnorgiVyKnyrgVgDU25lzfHeAxCuxmFtbx4YuD//xN4d2qrjv0ZSPvhWIO3sT6dyinIgHv68engM5w1dBNmc2TrEs/bFFKdXQx0KzXWZyxtEBvLrUDK0laWRk0UcoFDOz3ryj79jTRkqKbZ74trBk= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R741e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=guanrui.huang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0W4PzPfZ_1712990462; Received: from localhost(mailfrom:guanrui.huang@linux.alibaba.com fp:SMTPD_---0W4PzPfZ_1712990462) by smtp.aliyun-inc.com; Sat, 13 Apr 2024 14:41:03 +0800 From: Guanrui Huang To: maz@kernel.org Cc: yuzenghui@huawei.com, shannon.zhao@linux.alibaba.com, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Guanrui Huang Subject: [PATCH v4 2/2] irqchip/gic-v3-its: remove BUG_ON in its_vpe_irq_domain_alloc Date: Sat, 13 Apr 2024 14:40:51 +0800 Message-Id: <20240413064051.31315-2-guanrui.huang@linux.alibaba.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20240413064051.31315-1-guanrui.huang@linux.alibaba.com> References: <20240413064051.31315-1-guanrui.huang@linux.alibaba.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_234110_330000_BE8E64F9 X-CRM114-Status: UNSURE ( 7.87 ) 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 If vm is NULL in here, that means caller has a bug. BUG_ON in here is useless, this will paper over bug. So just remove this check. Signed-off-by: Guanrui Huang Acked-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3-its.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 2305f6b524a9..55c83e19719d 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -4521,8 +4521,6 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq struct page *vprop_page; int base, nr_ids, i, err = 0; - BUG_ON(!vm); - bitmap = its_lpi_alloc(roundup_pow_of_two(nr_irqs), &base, &nr_ids); if (!bitmap) return -ENOMEM;