Skip to content

Commit 4d62121

Browse files
author
Marc Zyngier
committed
KVM: arm64: vgic-debug: Avoid dereferencing NULL ITE pointer
Dan reports that iterating over a device ITEs can legitimately lead to a NULL pointer, and that the NULL check is placed *after* the pointer has already been dereferenced. Hoist the pointer check as early as possible and be done with it. Reported-by: Dan Carpenter <[email protected]> Fixes: 30deb51 ("KVM: arm64: vgic-its: Add debugfs interface to expose ITS tables") Link: https://lore.kernel.org/r/[email protected] Cc: Jing Zhang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 07212d1 commit 4d62121

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/arm64/kvm/vgic/vgic-debug.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ static int vgic_its_debug_show(struct seq_file *s, void *v)
490490
struct its_device *dev = iter->dev;
491491
struct its_ite *ite = iter->ite;
492492

493+
if (!ite)
494+
return 0;
495+
493496
if (list_is_first(&ite->ite_list, &dev->itt_head)) {
494497
seq_printf(s, "\n");
495498
seq_printf(s, "Device ID: 0x%x, Event ID Range: [0 - %llu]\n",
@@ -498,7 +501,7 @@ static int vgic_its_debug_show(struct seq_file *s, void *v)
498501
seq_printf(s, "-----------------------------------------------\n");
499502
}
500503

501-
if (ite && ite->irq && ite->collection) {
504+
if (ite->irq && ite->collection) {
502505
seq_printf(s, "%8u %8u %8u %8u %8u %2d\n",
503506
ite->event_id, ite->irq->intid, ite->irq->hwintid,
504507
ite->collection->target_addr,

0 commit comments

Comments
 (0)