Commit f71d82a6 authored by Alex Williamson's avatar Alex Williamson Committed by Greg Kroah-Hartman

vfio/pci: Clear error and request eventfd ctx after releasing

[ Upstream commit 5c5866c5 ]

The next use of the device will generate an underflow from the
stale reference.

Cc: Qian Cai <cai@lca.pw>
Fixes: 1518ac27 ("vfio/pci: fix memory leaks of eventfd ctx")
Reported-by: default avatarDaniel Wagner <dwagner@suse.de>
Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
Tested-by: default avatarDaniel Wagner <dwagner@suse.de>
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 590bcc21
......@@ -392,10 +392,14 @@ static void vfio_pci_release(void *device_data)
if (!(--vdev->refcnt)) {
vfio_spapr_pci_eeh_release(vdev->pdev);
vfio_pci_disable(vdev);
if (vdev->err_trigger)
if (vdev->err_trigger) {
eventfd_ctx_put(vdev->err_trigger);
if (vdev->req_trigger)
vdev->err_trigger = NULL;
}
if (vdev->req_trigger) {
eventfd_ctx_put(vdev->req_trigger);
vdev->req_trigger = NULL;
}
}
mutex_unlock(&driver_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment