[dpdk-dev] Memory leak in rte_pci_scan

Owen Hilyard ohilyard at iol.unh.edu
Mon Jun 14 22:41:34 CEST 2021


>From what I've seen so far, that fixes the PCI leak. That just leaves a few
other places. I'll try to get the complete list to you tomorrow, since
running the full set of unit tests takes quite a few hours when ASAN is
involved.

On Mon, Jun 14, 2021 at 6:30 AM David Marchand <david.marchand at redhat.com>
wrote:

> On Mon, Jun 14, 2021 at 11:11 AM David Marchand
> <david.marchand at redhat.com> wrote:
> >
> > On Tue, Jun 8, 2021 at 8:48 PM Owen Hilyard <ohilyard at iol.unh.edu>
> wrote:
> > >
> > > Hello All,
> > >
> > > As part of the community lab's work to deploy static analysis tools,
> we've
> > > been doing test runs of the various tools. One of the problems we
> found is
> > > that rte_pci_scan leaks 214368 Bytes every time it is run. There are
> also
> >
> > I suspect the "leak" is on pci device objects that are not released
> > unless hot(un)plugging.
> > Cc: Gaetan.
>
> I think I found a leak at:
> https://git.dpdk.org/dpdk/tree/drivers/bus/pci/linux/pci.c#n333
>
> For devices with no kernel driver, 'dev' will be leaked, since there
> is no reference to it in the pci device list.
>
> There will be more things to fix (there is a proposed patch on
> annotating the dpdk memory allocator for ASAN) but can you try this
> diff below with the mp patch [1] I sent to see if the situation gets
> better?
>
> diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
> index 0dc99e9cb2..5ea76bc867 100644
> --- a/drivers/bus/pci/linux/pci.c
> +++ b/drivers/bus/pci/linux/pci.c
> @@ -331,7 +331,7 @@ pci_scan_one(const char *dirname, const struct
> rte_pci_addr *addr)
>                 else
>                         dev->kdrv = RTE_PCI_KDRV_UNKNOWN;
>         } else {
> -               dev->kdrv = RTE_PCI_KDRV_NONE;
> +               free(dev);
>                 return 0;
>         }
>         /* device is valid, add in list (sorted) */
>
>
> 1:
> http://patchwork.dpdk.org/project/dpdk/patch/20210614091213.3953-1-david.marchand@redhat.com/
>
> --
> David Marchand
>
>


More information about the dev mailing list