FAILED: patch "[PATCH] KVM: Use goto to handle errors during memslot preparation" failed to apply to 5.10-stable tree
Subsystems (2)
Sasha Levin
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 23a205797cec86f391d0be886b9bc741e1262063
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 23a205797cec86f391d0be886b9bc741e1262063 Mon Sep 17 00:00:00 2001
From: Sean Christopherson <[email protected]>
Date: Mon, 21 Sep 2026 17:13:28 -0700
Subject: [PATCH] KVM: Use goto to handle errors during memslot preparation
Use a goto to unwind early memslot changes if preparing for a memslot operation fails. This will allow moving the creation of guest_memfd bindings into kvm_set_memslot() without needing to copy+paste the unwind logic.
No functional change intended.
--- virt/kvm/kvm_main.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
virt/kvm/kvm_main.c +16 -15
@@ -1931,21 +1931,8 @@ static int kvm_set_memslot(struct kvm *kvm, } r =kvm_prepare_memory_region (kvm, old, new, change); -if (r) { -/* -* For DELETE/MOVE, revert the above INVALID change. No -* modifications required since the original slot was preserved -* in the inactive slots. Changing the active memslots also -* release slots_arch_lock. -*/ -if (change ==KVM_MR_DELETE || change ==KVM_MR_MOVE ) { -kvm_activate_memslot (kvm, invalid_slot, old); -kfree (invalid_slot); - }else { -mutex_unlock (&kvm->slots_arch_lock); - } -return r; - } +if (r) + goto err;/* * For DELETE and MOVE, the working slot is now active as the INVALID
@@ -1977,6 +1964,20 @@ static int kvm_set_memslot(struct kvm *kvm,kvm_commit_memory_region (kvm, old, new, change);return 0 ; + +err: +/* +* For DELETE/MOVE, revert the above INVALID change. No modifications +* required since the original slot was preserved in the inactive slots. +* Changing the active memslots also release slots_arch_lock. +*/ +if (change ==KVM_MR_DELETE || change ==KVM_MR_MOVE ) { +kvm_activate_memslot (kvm, invalid_slot, old); +kfree (invalid_slot); + }else { +mutex_unlock (&kvm->slots_arch_lock); + } +return r; } static bool kvm_check_memslot_overlap(struct kvm_memslots *slots, int id,
Signature · 1 line
2.53.0