From nobody Sat Feb 7 08:45:09 2026 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0523E3399B for ; Thu, 18 Apr 2024 06:11:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.113 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713420670; cv=none; b=VNanwkzrjKOHYTzWyQO/+b1eJS18GcFgbA7sTFaaRNK7GLT4i9zwiSs25UaRM6NN9UoCFdLWYYcPCdEwWm1zDgPGnNOukGY2XmPqdzSAREmzFLRhC2IgnZerUq3BF+7jB2wsPJdJaaprI0vPT8Bd43/cOxwhYooe1dhZccyzzTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713420670; c=relaxed/simple; bh=9AIO2yFVH27qbIsLPRxjt7VAjn7rXGEkOnY2v3eJ17o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=htHueqwKlVR93ukGs4SMgYAZQn0fPTDnwU1YYx63IZ+BYn1Pi34nzqlhXrc57oCydVvCtWtrpRhtPmZ2EwfgNy8KXdvt+l8z9Omvv69T8PXGlw3PkAn4Jax5Dg+EnMG3Lay3+8NfI6MtR1cdv9zIFu4AkIpxYjqSVr4DS4vk+eg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=lvf9mHGB; arc=none smtp.client-ip=115.124.30.113 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="lvf9mHGB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1713420665; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=j5xhT/xn+HoEPFQEH51jOs/5tUc6xggDrAbLHMmno6Y=; b=lvf9mHGBzKKwIlkHJboK1N1o6Mn6G+sT94VWxPNSeARreiT8bB5Vxm/QWhxzPiybfLTTHOjeLv2ym5TcpSyIbwTDHNZCxFp1s1Zhjaad+Wkr5Kt/N12zHNcnOFvxHhC4hNKqFTgkY1nBlZlKY/AfG2gMWP3gOa7YuMhfirT1aRk= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R681e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=guanrui.huang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0W4nc51F_1713420663; Received: from localhost(mailfrom:guanrui.huang@linux.alibaba.com fp:SMTPD_---0W4nc51F_1713420663) by smtp.aliyun-inc.com; Thu, 18 Apr 2024 14:11:04 +0800 From: Guanrui Huang To: maz@kernel.org Cc: Markus.Elfring@web.de, 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 v5 1/2] irqchip/gic-v3-its: Fix double free on error Date: Thu, 18 Apr 2024 14:10:52 +0800 Message-Id: <20240418061053.96803-2-guanrui.huang@linux.alibaba.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20240418061053.96803-1-guanrui.huang@linux.alibaba.com> References: <20240418061053.96803-1-guanrui.huang@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Fixes: 7d75bbb4bc1a ("irqchip/gic-v3-its: Add VPE irq domain allocation/tea= rdown") Reviewed-by: Marc Zyngier Reviewed-by: Zenghui Yu Signed-off-by: Guanrui Huang --- 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_domai= n *domain, unsigned int virq irqd_set_resend_when_in_progress(irq_get_irq_data(virq + i)); } =20 - 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); =20 return err; } --=20 2.36.1 From nobody Sat Feb 7 08:45:09 2026 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEE4F657D4 for ; Thu, 18 Apr 2024 06:11:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713420672; cv=none; b=fnAwWeMU1uZoTAQwmIXMMBKMf9Fy9sd7qQPT2njBU5srWuECU7Gjnj/h/zTw5BlHsyfde3eWTjOpsGhEiR0LwD+jUF9Yg+6yZz7M5RAzf7vLxfXv2ze6CdnswWQM1p72KnbDUoEftdxTo8x7iZOtnLtrugdUayczwQngOzPTEzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713420672; c=relaxed/simple; bh=oowkozNmjGlW79z1tpDz5ibUt4Y1kS++h4P0yyQeaZs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GAb2+etOpit9Fmi8PY71pmOiY8HpAM2nm2qX0HmGk4CEmmjtCoOd2lxnuHJ/KNUK3nzofv9vU09n9qjVR2gJbgZqYEFzcH8PpiucPgIPD5/EXVui6yD2NUlsknUv8ZhCqLRXlnHgby3WdL+pcps3eYPcggqIhYXiAFQ4rp7CxU0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=jYShVdTS; arc=none smtp.client-ip=115.124.30.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="jYShVdTS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1713420667; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=9VRYN2yD2V4/lnqB6El/L7sh5NLW7Fn4xEq3YHYUc+U=; b=jYShVdTScQQXvUNEoScD6ccm/SgKWkLB3c5EjSJfw/mA+CwVdBZxjNne9XphNWBE07xWCefusL2idiXNRjG7TCb6jFyHCvDtNlrIQD16uYEjRhRPzZL2gG4BUP/b4oxLdRBaoUXAalfK+tqJrZ8VOBfkCoVCiWRGJpoQkWGmbEY= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=guanrui.huang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0W4nb0yv_1713420666; Received: from localhost(mailfrom:guanrui.huang@linux.alibaba.com fp:SMTPD_---0W4nb0yv_1713420666) by smtp.aliyun-inc.com; Thu, 18 Apr 2024 14:11:06 +0800 From: Guanrui Huang To: maz@kernel.org Cc: Markus.Elfring@web.de, 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 v5 2/2] irqchip/gic-v3-its: remove BUG_ON in its_vpe_irq_domain_alloc Date: Thu, 18 Apr 2024 14:10:53 +0800 Message-Id: <20240418061053.96803-3-guanrui.huang@linux.alibaba.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20240418061053.96803-1-guanrui.huang@linux.alibaba.com> References: <20240418061053.96803-1-guanrui.huang@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This BUG_ON() is useless, because the same effect will be obtained=20 by letting the code run its course and vm being dereferenced, triggering an exception. So just remove this check. Acked-by: Marc Zyngier Signed-off-by: Guanrui Huang Reviewed-by: Zenghui Yu --- 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 =3D 0; =20 - BUG_ON(!vm); - bitmap =3D its_lpi_alloc(roundup_pow_of_two(nr_irqs), &base, &nr_ids); if (!bitmap) return -ENOMEM; --=20 2.36.1