Skip to content

Commit

Permalink
vfio/pci: Clear error and request eventfd ctx after releasing
Browse files Browse the repository at this point in the history
[ Upstream commit 5c5866c ]

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

Cc: Qian Cai <cai@lca.pw>
Fixes: 1518ac2 ("vfio/pci: fix memory leaks of eventfd ctx")
Reported-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Tested-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
awilliam authored and gregkh committed Oct 1, 2020
1 parent 781a4bf commit 3bb9b0a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/vfio/pci/vfio_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,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(&vdev->reflck->lock);
Expand Down

0 comments on commit 3bb9b0a

Please sign in to comment.