KVM: PPC: Book3S HV: XIVE: fix rollback when kvmppc_xive_create fails
authorCédric Le Goater <clg@kaod.org>
Thu, 18 Jul 2019 21:51:54 +0000 (23:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Jul 2019 05:24:57 +0000 (07:24 +0200)
commit373108886c3120cb92f50b92016087d9b562575b
tree75ca59ec25ca858d840b3a55a21a20567fbab024
parent13135247b77192d51e7bd6f95220e645ab1b6537
KVM: PPC: Book3S HV: XIVE: fix rollback when kvmppc_xive_create fails

commit 9798f4ea71eaf8eaad7e688c5b298528089c7bf8 upstream.

The XIVE device structure is now allocated in kvmppc_xive_get_device()
and kfree'd in kvmppc_core_destroy_vm(). In case of an OPAL error when
allocating the XIVE VPs, the kfree() call in kvmppc_xive_*create()
will result in a double free and corrupt the host memory.

Fixes: 5422e95103cf ("KVM: PPC: Book3S HV: XIVE: Replace the 'destroy' method by a 'release' method")
Cc: stable@vger.kernel.org # v5.2+
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/6ea6998b-a890-2511-01d1-747d7621eb19@kaod.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/kvm/book3s_xive.c
arch/powerpc/kvm/book3s_xive_native.c