From: Marc Zyngier Date: Thu, 16 Nov 2017 17:58:18 +0000 (+0000) Subject: KVM: arm/arm64: vgic-its: Check result of allocation before use X-Git-Tag: v4.19~2003^2~6^2~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=686f294f2f1ae40705283dd413ca1e4c14f20f93;p=platform%2Fkernel%2Flinux-rpi.git KVM: arm/arm64: vgic-its: Check result of allocation before use We miss a test against NULL after allocation. Fixes: 6d03a68f8054 ("KVM: arm64: vgic-its: Turn device_id validation into generic ID validation") Cc: stable@vger.kernel.org # 4.8 Reported-by: AKASHI Takahiro Acked-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index cb2d0a2..8e633bd 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -821,6 +821,8 @@ static int vgic_its_alloc_collection(struct vgic_its *its, return E_ITS_MAPC_COLLECTION_OOR; collection = kzalloc(sizeof(*collection), GFP_KERNEL); + if (!collection) + return -ENOMEM; collection->collection_id = coll_id; collection->target_addr = COLLECTION_NOT_MAPPED;