KVM: arm64: vgic-its: Handle errors from vgic_add_lpi
authorChristoffer Dall <christoffer.dall@linaro.org>
Mon, 1 Aug 2016 18:25:33 +0000 (20:25 +0200)
committerChristoffer Dall <christoffer.dall@linaro.org>
Wed, 10 Aug 2016 09:41:35 +0000 (11:41 +0200)
commit99e5e886a0a59df267ff6838f763b789847df982
treea3f144ed79a1cd132ab8c3667a25cedc685e0461
parentfd837b08d98c0c9f4f31998f2ed55b9d8694082c
KVM: arm64: vgic-its: Handle errors from vgic_add_lpi

During low memory conditions, we could be dereferencing a NULL pointer
when vgic_add_lpi fails to allocate memory.

Consider for example this call sequence:

  vgic_its_cmd_handle_mapi
      itte->irq = vgic_add_lpi(kvm, lpi_nr);
          update_lpi_config(kvm, itte->irq, NULL);
              ret = kvm_read_guest(kvm, propbase + irq->intid
                                             ^^^^
     kaboom?

Instead, return an error pointer from vgic_add_lpi and check the return
value from its single caller.

Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
virt/kvm/arm/vgic/vgic-its.c