Re: [PATCH 09/10] irqchip/gic-v5: Clean the allocated linear device table size

From
Lorenzo Pieralisi <lpieralisi@kernel.org>
Date
2026-11-02 14:46:08
Also in
lkml
Reply to
Sascha Bischoff, 2026-11-02
On Mon, Nov 02, 2026 at 01:33:02PM +0000, Sascha Bischoff wrote:
quoted hunk ↗ jump to hunk
When the linear device table exceeds the kmalloc limit, the driver
caps the DeviceID width before allocation but keeps the original size
for cache maintenance. On a noncoherent ITS, this cleans beyond the
allocated table.

Recalculate the size after capping the DeviceID width.

Fixes: 57d72196dfc85 ("irqchip/gic-v5: Add GICv5 ITS support")
Signed-off-by: Sascha Bischoff <redacted>
---
 drivers/irqchip/irq-gic-v5-its.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/drivers/irqchip/irq-gic-v5-its.c b/drivers/irqchip/irq-gic-v5-its.c
index 4de07bbdc4923..c0f3982229194 100644
--- a/drivers/irqchip/irq-gic-v5-its.c
+++ b/drivers/irqchip/irq-gic-v5-its.c
@@ -601,6 +601,7 @@ static int gicv5_its_alloc_devtab_linear(struct gicv5_its_chip_data *its,
 		pr_warn("Limiting device ID bits from %u to %u\n",
 			device_id_bits, device_id_cap);
 		device_id_bits = device_id_cap;
+		sz = BIT_ULL(device_id_bits) * sizeof(*devtab);
 	}
 
Or sz = KMALLOC_MAX_SIZE;

that's what we are doing after all.

I wonder whether moving:

sz = BIT_ULL(device_id_bits) * sizeof(*devtab);

after the capping out of the if and do:

if (BIT_ULL(device_id_bits) * sizeof(*devtab) > KMALLOC_MAX_SIZE)

to check whether mem alloc should be capped makes this any easier
to read.

Regardless, this patch is a fix and it is right to make it as small
as possible:

Acked-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
 	devtab = kcalloc(BIT(device_id_bits), sizeof(*devtab), GFP_KERNEL);

-- 
2.34.1
  
Thread (27 messages) 27 messages, 2 authors, last reply 13d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help