FAILED: patch "[PATCH] LoongArch: KVM: Clear device pointer in irqchip destroy" failed to apply to 6.18-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.18-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-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x a9ce1a00afb0402668877d37c04ffd0e53d48832
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026112532-hamster-banister-f7da@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From a9ce1a00afb0402668877d37c04ffd0e53d48832 Mon Sep 17 00:00:00 2001
From: Tao Cui <[email protected]>
Date: Tue, 10 Nov 2026 17:20:39 +0800
Subject: [PATCH] LoongArch: KVM: Clear device pointer in irqchip destroy
callbacks
The destroy callbacks of the four irqchip devices free the device structure without clearing kvm->arch.{ipi,eiointc,pch_pic,dmsintc}, leaving a dangling pointer. ops->destroy() is not only called at VM teardown but also when KVM_CREATE_DEVICE succeeds and the following anon_inode_getfd() fails (e.g. under RLIMIT_NOFILE); the VM stays alive, kvm_arch_irqchip_in_kernel() still reports true, and interrupt injection dereferences the freed device.
Clear the pointer when destroying.
arch/loongarch/kvm/intc/dmsintc.c +1 -0
@@ -146,6 +146,7 @@ static void kvm_dmsintc_destroy(struct kvm_device *dev)return ;kfree (dev->kvm->arch.dmsintc); + dev->kvm->arch.dmsintc =NULL ;kfree (dev); }
arch/loongarch/kvm/intc/eiointc.c +1 -0
@@ -675,6 +675,7 @@ static void kvm_eiointc_destroy(struct kvm_device *dev) kvm = dev->kvm; eiointc = kvm->arch.eiointc; + kvm->arch.eiointc =NULL ;mutex_lock (&kvm->slots_lock);kvm_io_bus_unregister_dev (kvm,KVM_IOCSR_BUS , &eiointc->device);kvm_io_bus_unregister_dev (kvm,KVM_IOCSR_BUS , &eiointc->device_vext);
arch/loongarch/kvm/intc/ipi.c +1 -0
@@ -441,6 +441,7 @@ static void kvm_ipi_destroy(struct kvm_device *dev) kvm = dev->kvm; ipi = kvm->arch.ipi; + kvm->arch.ipi =NULL ;mutex_lock (&kvm->slots_lock);kvm_io_bus_unregister_dev (kvm,KVM_IOCSR_BUS , &ipi->device);mutex_unlock (&kvm->slots_lock);
arch/loongarch/kvm/intc/pch_pic.c +1 -0
@@ -483,6 +483,7 @@ static void kvm_pch_pic_destroy(struct kvm_device *dev) kvm = dev->kvm; s = kvm->arch.pch_pic; + kvm->arch.pch_pic =NULL ;/* unregister pch pic device and free it's memory */ mutex_lock (&kvm->slots_lock);kvm_io_bus_unregister_dev (kvm,KVM_MMIO_BUS , &s->device);