Skip to content

Commit

Permalink
KVM: PPC: Book3S HV: XIVE: fix rollback when kvmppc_xive_create fails
Browse files Browse the repository at this point in the history
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: 5422e95 ("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
  • Loading branch information
Cédric Le Goater authored and Michael Ellerman committed Jul 19, 2019
1 parent 4d202c8 commit 9798f4e
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions arch/powerpc/kvm/book3s_xive.c
Original file line number Diff line number Diff line change
@@ -1986,10 +1986,8 @@ static int kvmppc_xive_create(struct kvm_device *dev, u32 type)

xive->single_escalation = xive_native_has_single_escalation();

if (ret) {
kfree(xive);
if (ret)
return ret;
}

return 0;
}
4 changes: 2 additions & 2 deletions arch/powerpc/kvm/book3s_xive_native.c
Original file line number Diff line number Diff line change
@@ -1090,9 +1090,9 @@ static int kvmppc_xive_native_create(struct kvm_device *dev, u32 type)
xive->ops = &kvmppc_xive_native_ops;

if (ret)
kfree(xive);
return ret;

return ret;
return 0;
}

/*

0 comments on commit 9798f4e

Please sign in to comment.