public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cornelia Huck <cohuck@redhat.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	dwagner@suse.de, cai@lca.pw
Subject: Re: [PATCH] vfio/pci: Clear error and request eventfd ctx after releasing
Date: Wed, 17 Jun 2020 07:56:04 +0200	[thread overview]
Message-ID: <20200617075604.67b47078.cohuck@redhat.com> (raw)
In-Reply-To: <159234276956.31057.6902954364435481688.stgit@gimli.home>

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>


  parent reply	other threads:[~2020-06-17  5:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2020-06-17  6:51 ` Daniel Wagner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200617075604.67b47078.cohuck@redhat.com \
    --to=cohuck@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=cai@lca.pw \
    --cc=dwagner@suse.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox