android_kernel_motorola_sm6375/drivers/virtio
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Wolfram Sang b788ad3b24 virtio-mmio: don't break lifecycle of vm_dev
[ Upstream commit 55c91fedd03d7b9cf0c5199b2eb12b9b8e95281a ]

vm_dev has a separate lifecycle because it has a 'struct device'
embedded. Thus, having a release callback for it is correct.

Allocating the vm_dev struct with devres totally breaks this protection,
though. Instead of waiting for the vm_dev release callback, the memory
is freed when the platform_device is removed. Resulting in a
use-after-free when finally the callback is to be called.

To easily see the problem, compile the kernel with
CONFIG_DEBUG_KOBJECT_RELEASE and unbind with sysfs.

The fix is easy, don't use devres in this case.

Found during my research about object lifetime problems.

Fixes: 7eb781b1bb ("virtio_mmio: add cleanup for virtio_mmio_probe")
Signed-off-by: Wolfram Sang <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
2023-08-30 16:27:15 +02:00
..
Kconfig
Makefile
virtio.c
virtio_balloon.c
virtio_input.c
virtio_mmio.c virtio-mmio: don't break lifecycle of vm_dev 2023-08-30 16:27:15 +02:00
virtio_pci_common.c
virtio_pci_common.h
virtio_pci_legacy.c
virtio_pci_modern.c
virtio_ring.c treewide: Remove uninitialized_var() usage 2023-06-09 10:29:01 +02:00