Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp239567ybt; Tue, 16 Jun 2020 22:58:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMKMp4Ca0McblLkh9BpfAEhtmvMXoY5CuJyiLrRrZaI8dwajBp6nPIVPnBO9tZKiOqiK9y X-Received: by 2002:a17:906:1e92:: with SMTP id e18mr6309686ejj.254.1592373528569; Tue, 16 Jun 2020 22:58:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592373528; cv=none; d=google.com; s=arc-20160816; b=v/FZlDaUa7zbmlN65J/CHJXdW3Sk8uNBydaWZIPyXM4d7RiAb9o4duy7zavyyiQPoY Sd9Knb09AHScJ+Wh0+uYiqTPW8laWGp1f48x+qzBgHS+t1/j2Dm/Egr3DfSDK1sR8v4k GxGMJkA6Xm4H+so2qshDxjT/66co2a/bfiI/WUnxyYjQs2rFrhiJzVR46WZA9leYaHnq DCYJRqKgNlGhuqsDA9kojW4Gv8Gkzy8YEC2AOGnrHiUMJMTfqN2ErQ61lJCzq5eIRIIo XZBRnuujmik3p+VzjD1fCyAwU9xv/i4gmdyPsTGqMJk/WeHJOPi/4R8uuuEW7OsX46Z3 mi1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=bqylOELuu5u+OMaXH6+BHxzbmV1N3q++LSowq/nIA1I=; b=vgfTjSbD7J13wASDD2vUR6ctgwLJf25s5owKLZF+hdGONZzKLzDnGiZl0SBicZA9fd PGXjZzACL25rRzn6JnRnd5oY595p6X5/2VM0UXfJ+S3E7RTwcpzPrUfGw5VEY3NEdy6f V1IHIZc7BAIlP3n2JUEYlMII/zvvgcrHawlvUF8+5CSntz+fySKk3OMIvGw90+qbiK7d KGPxepgg4n1xgpw2hDzZIN5z6MDc4QYITzYjxCWl4lbQD5NF4957h2S1crKPEJ/qGL8Y mfOUhwtqUxzblJaHtYO9+6cR0Anrj3CgRgCBW0weZLfl684dXMvun5UFBFVbX9QF9PI2 7NEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=if8rRWzP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm2si11150494edb.370.2020.06.16.22.58.25; Tue, 16 Jun 2020 22:58:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=if8rRWzP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726853AbgFQF4Q (ORCPT + 99 others); Wed, 17 Jun 2020 01:56:16 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:59255 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725851AbgFQF4P (ORCPT ); Wed, 17 Jun 2020 01:56:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592373374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bqylOELuu5u+OMaXH6+BHxzbmV1N3q++LSowq/nIA1I=; b=if8rRWzPXbrRTcUgVKnHdwGfxjxcgY+C/09WD+Y9yq70sS35gzJmV/haFHiGUrQyT5CoEr ypBHKVcHMxQY33G10izf+25Lazen9clOsDPbXpJzX6wiJfYSZFiZ2ELPja76TYGBQUG63J g0zkWylheEMGiuQ0w67NZ9EBNh7Xyu8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-349-P4RaW-KYNnSocYt9_L0J7w-1; Wed, 17 Jun 2020 01:56:12 -0400 X-MC-Unique: P4RaW-KYNnSocYt9_L0J7w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EEA79188362F; Wed, 17 Jun 2020 05:56:10 +0000 (UTC) Received: from gondolin (ovpn-112-222.ams2.redhat.com [10.36.112.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F03060CC0; Wed, 17 Jun 2020 05:56:06 +0000 (UTC) Date: Wed, 17 Jun 2020 07:56:04 +0200 From: Cornelia Huck To: Alex Williamson 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 Message-ID: <20200617075604.67b47078.cohuck@redhat.com> In-Reply-To: <159234276956.31057.6902954364435481688.stgit@gimli.home> References: <159234276956.31057.6902954364435481688.stgit@gimli.home> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 16 Jun 2020 15:26:36 -0600 Alex Williamson wrote: > The next use of the device will generate an underflow from the > stale reference. > > Cc: Qian Cai > Fixes: 1518ac272e78 ("vfio/pci: fix memory leaks of eventfd ctx") > Reported-by: Daniel Wagner > Signed-off-by: Alex Williamson > --- > 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