mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-11 07:11:51 -04:00
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 <dan.carpenter@linaro.org>
Fixes: 30deb51a67 ("KVM: arm64: vgic-its: Add debugfs interface to expose ITS tables")
Link: https://lore.kernel.org/r/aDBylI1YnjPatAbr@stanley.mountain
Cc: Jing Zhang <jingzhangos@google.com>
Link: https://lore.kernel.org/r/20250530091647.1152489-1-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
This commit is contained in:
@@ -490,6 +490,9 @@ static int vgic_its_debug_show(struct seq_file *s, void *v)
|
||||
struct its_device *dev = iter->dev;
|
||||
struct its_ite *ite = iter->ite;
|
||||
|
||||
if (!ite)
|
||||
return 0;
|
||||
|
||||
if (list_is_first(&ite->ite_list, &dev->itt_head)) {
|
||||
seq_printf(s, "\n");
|
||||
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)
|
||||
seq_printf(s, "-----------------------------------------------\n");
|
||||
}
|
||||
|
||||
if (ite && ite->irq && ite->collection) {
|
||||
if (ite->irq && ite->collection) {
|
||||
seq_printf(s, "%8u %8u %8u %8u %8u %2d\n",
|
||||
ite->event_id, ite->irq->intid, ite->irq->hwintid,
|
||||
ite->collection->target_addr,
|
||||
|
||||
Reference in New Issue
Block a user