[PATCH v2] bus: fix memleak during pci device cleanup
David Marchand
david.marchand at redhat.com
Thu Oct 20 11:19:52 CEST 2022
On Wed, Oct 19, 2022 at 2:35 PM Kevin Laatz <kevin.laatz at intel.com> wrote:
>
> During PCI bus device cleanup some interrupt handle pointers and the
> bus_info pointer are not being free'd, leading to memory leaks.
> This patch fixes the memory leaks by ensuring they are free'd during
> device cleanup on exit.
>
> Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
>
> Signed-off-by: Kevin Laatz <kevin.laatz at intel.com>
>
> ---
> v2: remove redundant NULL checks
> ---
> drivers/bus/pci/pci_common.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
> index 7f598667fe..71cd3f59ad 100644
> --- a/drivers/bus/pci/pci_common.c
> +++ b/drivers/bus/pci/pci_common.c
> @@ -456,6 +456,16 @@ pci_cleanup(void)
> }
> dev->driver = NULL;
> dev->device.driver = NULL;
> +
> + /* free interrupt handles */
> + 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;
> +
> + free(dev->bus_info);
> + dev->bus_info = NULL;
> +
> free(dev);
I'll do an update when applying: here, it is better to use
pci_free(dev); which was introduced at the same time bus_info was.
> }
>
> --
> 2.31.1
>
Reviewed-by: David Marchand <david.marchand at redhat.com>
--
David Marchand
More information about the dev
mailing list