KVM: arm64: vgic-debug: Avoid dereferencing NULL ITE pointer
authorMarc Zyngier <maz@kernel.org>
Fri, 30 May 2025 09:16:47 +0000 (10:16 +0100)
committerMarc Zyngier <maz@kernel.org>
Fri, 30 May 2025 09:24:49 +0000 (10:24 +0100)
commit4d62121ce9b58ea23c8d62207cbc604e98ecdc0a
treee5b532e7b5107a32050a8554daed504c631f8e44
parent07212d16adc7a02810e1641c2721762751ce4f88
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: 30deb51a677b ("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>
arch/arm64/kvm/vgic/vgic-debug.c