On Wed, 24 Jun 2026 at 08:51, David Marchand <[email protected]> wrote:
> > > diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
> > > index fd18b8772b..791e9a7b49 100644
> > > --- a/drivers/bus/pci/pci_common.c
> > > +++ b/drivers/bus/pci/pci_common.c
> > > @@ -344,6 +344,10 @@ pci_cleanup(void)
> > >                       rte_errno = errno;
> > >                       error = -1;
> > >               }
> > > +
> > > +             if (drv->drv_flags & RTE_PCI_DRV_NEED_MAPPING)
> > > +                     rte_pci_unmap_device(dev);
> >
> > rte_pci_unmap_device() also invoked in some drivers remove callback, e.g.
> >   eth_virtio_pci_uninit()
> >   ifcvf_pci_remove()
> >   ...
> >
> > In this case it may doulbe-free
>
> $ git grep -l rte_pci_unmap_device drivers :^drivers/bus/pci | cut -d
> / -f 2,3 | sort -u
> net/nbl
> net/virtio
> net/xsc
> vdpa/ifc
> vdpa/nfp
> vdpa/sfc
>
> Those drivers do not set RTE_PCI_DRV_NEED_MAPPING and have their own
> logic when it comes to mapping/unmapping resources.
>
> $ for drv in $(git grep -l rte_pci_unmap_device drivers
> :^drivers/bus/pci | cut -d / -f 2,3 | sort -u); do git grep -l
> RTE_PCI_DRV_NEED_MAPPING drivers/$drv; done
> drivers/vdpa/nfp/nfp_vdpa.c
>
> I suspect calling rte_pci_unmap_device twice will end up with some
> error before a double free.
> Worth a fix on vdpa/nfp regardless, I'll work on it quickly.

Just a note.
On the principle, the vdpa/nfp driver has a double unmap bug on device
unplug, regardless of this change of mine.


-- 
David Marchand

Reply via email to