linux-brain/include
Sean Christopherson 7d1bc32d64 KVM: Stop looking for coalesced MMIO zones if the bus is destroyed
commit 5d3c4c79384af06e3c8e25b7770b6247496b4417 upstream.

Abort the walk of coalesced MMIO zones if kvm_io_bus_unregister_dev()
fails to allocate memory for the new instance of the bus.  If it can't
instantiate a new bus, unregister_dev() destroys all devices _except_ the
target device.   But, it doesn't tell the caller that it obliterated the
bus and invoked the destructor for all devices that were on the bus.  In
the coalesced MMIO case, this can result in a deleted list entry
dereference due to attempting to continue iterating on coalesced_zones
after future entries (in the walk) have been deleted.

Opportunistically add curly braces to the for-loop, which encompasses
many lines but sneaks by without braces due to the guts being a single
if statement.

Fixes: f65886606c2d ("KVM: fix memory leak in kvm_io_bus_unregister_dev()")
Cc: stable@vger.kernel.org
Reported-by: Hao Sun <sunhao.th@gmail.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210412222050.876100-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-14 09:44:15 +02:00
..
acpi ACPI: scan: Use unique number for instance_no 2021-03-30 14:35:28 +02:00
asm-generic vmlinux.lds.h: add DWARF v5 sections 2021-03-04 10:26:09 +01:00
clocksource
crypto crypto: api - check for ERR pointers in crypto_destroy_tfm() 2021-05-11 14:04:05 +02:00
drm iommu/vt-d: Move intel_iommu_gfx_mapped to Intel IOMMU header 2020-11-24 13:29:17 +01:00
dt-bindings clk: imx8mn: Fix incorrect clock defines 2020-03-18 07:17:55 +01:00
keys KEYS: Don't write out to userspace while holding key semaphore 2020-04-23 10:36:45 +02:00
kvm
linux KVM: Stop looking for coalesced MMIO zones if the bus is destroyed 2021-05-14 09:44:15 +02:00
math-emu
media media: rc: compile rc-cec.c into rc-core 2021-03-17 17:03:40 +01:00
misc
net Bluetooth: verify AMP hci_chan before amp_destroy 2021-05-14 09:44:10 +02:00
pcmcia
ras
rdma RDMA/umem: Fix signature of stub ib_umem_find_best_pgsz() 2020-10-29 09:57:47 +01:00
scsi Fix misc new gcc warnings 2021-05-11 14:04:16 +02:00
soc irqchip/eznps: Fix build error for !ARC700 builds 2020-09-17 13:47:47 +02:00
sound ALSA: hda: intel-nhlt: verify config type 2021-03-09 11:09:39 +01:00
target scsi: target: core: Add cmd length set before cmd complete 2021-03-17 17:03:45 +01:00
trace writeback: Drop I_DIRTY_TIME_EXPIRE 2021-01-30 13:54:11 +01:00
uapi usb: webcam: Invalid size of Processing Unit Descriptor 2021-05-11 14:04:05 +02:00
vdso
video
xen Xen/gntdev: correct error checking in gntdev_map_grant_pages() 2021-02-23 15:02:26 +01:00