From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8B55DA0C41; Thu, 4 Nov 2021 15:16:11 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 52FD842745; Thu, 4 Nov 2021 15:16:11 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 2116242734 for ; Thu, 4 Nov 2021 15:16:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636035369; 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=8oKnWaDjvr9CkwxdeIxaMhjJeU7sG5Rwq2qAUBxiUeI=; b=Lz3ivQw5Ulom0uA1959HNx6sdacwZaTDPXkxNb5LHwgVPK/k2kvnTKA2ryvOvPECzdSOM3 bp91e0Yll4A+jMuWxtk1SSSyAsbigpYzzo3OUdmKsxFKQGwQw6sANoeQFcI7GuSaXJj0y7 ydWDV59mPVSBrng6Fmpv7c9dZmoIKtU= 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-56-Yar97eMkPnqGy-FF4fUwrQ-1; Thu, 04 Nov 2021 10:16:08 -0400 X-MC-Unique: Yar97eMkPnqGy-FF4fUwrQ-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 E7230343CF; Thu, 4 Nov 2021 14:16:06 +0000 (UTC) Received: from [10.39.208.16] (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6E7460C7F; Thu, 4 Nov 2021 14:16:00 +0000 (UTC) Message-ID: Date: Thu, 4 Nov 2021 15:15:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 To: David Marchand , dev@dpdk.org Cc: yanx.xia@intel.com, Hyong Youb Kim , Harman Kalra References: <20211103111615.6271-1-david.marchand@redhat.com> From: Maxime Coquelin In-Reply-To: <20211103111615.6271-1-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] bus/pci: fix use after free on unplug X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 11/3/21 12:16, David Marchand wrote: > rte_pci_unmap_device() needs intr_handle objects to unregister > callbacks. > > Bugzilla ID: 845 > Fixes: d61138d4f0e2 ("drivers: remove direct access to interrupt handle") > > Signed-off-by: David Marchand > --- > drivers/bus/pci/pci_common.c | 17 +++++++++-------- > 1 file changed, 9 insertions(+), 8 deletions(-) > > diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c > index f8fff2c98e..4a3a87f24f 100644 > --- a/drivers/bus/pci/pci_common.c > +++ b/drivers/bus/pci/pci_common.c > @@ -271,10 +271,6 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, > return ret; /* no rollback if already succeeded earlier */ > if (ret) { > dev->driver = NULL; > - rte_intr_instance_free(dev->vfio_req_intr_handle); > - dev->vfio_req_intr_handle = NULL; > - rte_intr_instance_free(dev->intr_handle); > - dev->intr_handle = NULL; > if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) && > /* Don't unmap if device is unsupported and > * driver needs mapped resources. > @@ -282,6 +278,10 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, > !(ret > 0 && > (dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES))) > rte_pci_unmap_device(dev); > + rte_intr_instance_free(dev->vfio_req_intr_handle); > + dev->vfio_req_intr_handle = NULL; > + rte_intr_instance_free(dev->intr_handle); > + dev->intr_handle = NULL; > } else { > dev->device.driver = &dr->driver; > } > @@ -322,15 +322,16 @@ rte_pci_detach_dev(struct rte_pci_device *dev) > /* clear driver structure */ > dev->driver = NULL; > dev->device.driver = NULL; > - rte_intr_instance_free(dev->intr_handle); > - dev->intr_handle = NULL; > - rte_intr_instance_free(dev->vfio_req_intr_handle); > - dev->vfio_req_intr_handle = NULL; > > if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) > /* unmap resources for devices that use igb_uio */ > rte_pci_unmap_device(dev); > > + rte_intr_instance_free(dev->intr_handle); > + dev->intr_handle = NULL; > + rte_intr_instance_free(dev->vfio_req_intr_handle); > + dev->vfio_req_intr_handle = NULL; > + > return 0; > } > > Reviewed-by: Maxime Coquelin Thanks, Maxime