* [PATCH] vfio/pci: Clear error and request eventfd ctx after releasing
@ 2020-06-16 21:26 Alex Williamson
2020-06-16 22:34 ` Qian Cai
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alex Williamson @ 2020-06-16 21:26 UTC (permalink / raw)
To: alex.williamson; +Cc: linux-kernel, kvm, cohuck, dwagner, cai
The next use of the device will generate an underflow from the
stale reference.
Cc: Qian Cai <cai@lca.pw>
Fixes: 1518ac272e78 ("vfio/pci: fix memory leaks of eventfd ctx")
Reported-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
drivers/vfio/pci/vfio_pci.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 7c0779018b1b..f634c81998bb 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -521,10 +521,14 @@ static void vfio_pci_release(void *device_data)
vfio_pci_vf_token_user_add(vdev, -1);
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);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] vfio/pci: Clear error and request eventfd ctx after releasing
2020-06-16 21:26 [PATCH] vfio/pci: Clear error and request eventfd ctx after releasing Alex Williamson
@ 2020-06-16 22:34 ` Qian Cai
2020-06-17 5:56 ` Cornelia Huck
2020-06-17 6:51 ` Daniel Wagner
2 siblings, 0 replies; 4+ messages in thread
From: Qian Cai @ 2020-06-16 22:34 UTC (permalink / raw)
To: Alex Williamson; +Cc: linux-kernel, kvm, cohuck, dwagner
> On Jun 16, 2020, at 5:26 PM, Alex Williamson <alex.williamson@redhat.com> wrote:
>
> The next use of the device will generate an underflow from the
> stale reference.
Thanks Alex for taking care of this. I suppose my tests were too basic and never able to catch this underflow in the first place.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vfio/pci: Clear error and request eventfd ctx after releasing
2020-06-16 21:26 [PATCH] vfio/pci: Clear error and request eventfd ctx after releasing Alex Williamson
2020-06-16 22:34 ` Qian Cai
@ 2020-06-17 5:56 ` Cornelia Huck
2020-06-17 6:51 ` Daniel Wagner
2 siblings, 0 replies; 4+ messages in thread
From: Cornelia Huck @ 2020-06-17 5:56 UTC (permalink / raw)
To: Alex Williamson; +Cc: linux-kernel, kvm, dwagner, cai
On Tue, 16 Jun 2020 15:26:36 -0600
Alex Williamson <alex.williamson@redhat.com> wrote:
> The next use of the device will generate an underflow from the
> stale reference.
>
> Cc: Qian Cai <cai@lca.pw>
> Fixes: 1518ac272e78 ("vfio/pci: fix memory leaks of eventfd ctx")
> Reported-by: Daniel Wagner <dwagner@suse.de>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
> drivers/vfio/pci/vfio_pci.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index 7c0779018b1b..f634c81998bb 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -521,10 +521,14 @@ static void vfio_pci_release(void *device_data)
> vfio_pci_vf_token_user_add(vdev, -1);
> 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);
>
Clearing this seems like the right thing to do.
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vfio/pci: Clear error and request eventfd ctx after releasing
2020-06-16 21:26 [PATCH] vfio/pci: Clear error and request eventfd ctx after releasing Alex Williamson
2020-06-16 22:34 ` Qian Cai
2020-06-17 5:56 ` Cornelia Huck
@ 2020-06-17 6:51 ` Daniel Wagner
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Wagner @ 2020-06-17 6:51 UTC (permalink / raw)
To: Alex Williamson; +Cc: linux-kernel, kvm, cohuck, cai
Hi Alex,
On Tue, Jun 16, 2020 at 03:26:36PM -0600, Alex Williamson wrote:
> The next use of the device will generate an underflow from the
> stale reference.
>
> Cc: Qian Cai <cai@lca.pw>
> Fixes: 1518ac272e78 ("vfio/pci: fix memory leaks of eventfd ctx")
> Reported-by: Daniel Wagner <dwagner@suse.de>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Thanks for the quick fix. I gave it a try and the warning is gone.
Tested-by: Daniel Wagner <dwagner@suse.de>
Thanks,
Daniel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-17 6:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-16 21:26 [PATCH] vfio/pci: Clear error and request eventfd ctx after releasing Alex Williamson
2020-06-16 22:34 ` Qian Cai
2020-06-17 5:56 ` Cornelia Huck
2020-06-17 6:51 ` Daniel Wagner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).