Date: Thu, 9 May 2019 10:23:42 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347387 - head/sys/compat/linuxkpi/common/src Message-ID: <201905091023.x49ANgDw009962@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Thu May 9 10:23:42 2019 New Revision: 347387 URL: https://svnweb.freebsd.org/changeset/base/347387 Log: Fix memory leak of PCI BUS structure in the LinuxKPI. MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/compat/linuxkpi/common/src/linux_pci.c Modified: head/sys/compat/linuxkpi/common/src/linux_pci.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_pci.c Thu May 9 09:49:07 2019 (r347386) +++ head/sys/compat/linuxkpi/common/src/linux_pci.c Thu May 9 10:23:42 2019 (r347387) @@ -251,12 +251,10 @@ linux_pci_attach(device_t dev) if (error) goto out_dma_init; - if (pdev->bus == NULL) { - pbus = malloc(sizeof(*pbus), M_DEVBUF, M_WAITOK | M_ZERO); - pbus->self = pdev; - pbus->number = pci_get_bus(dev); - pdev->bus = pbus; - } + pbus = malloc(sizeof(*pbus), M_DEVBUF, M_WAITOK | M_ZERO); + pbus->self = pdev; + pbus->number = pci_get_bus(dev); + pdev->bus = pbus; spin_lock(&pci_lock); list_add(&pdev->links, &pci_devices); @@ -268,6 +266,7 @@ linux_pci_attach(device_t dev) return (0); out_probe: + free(pdev->bus, M_DEVBUF); linux_pdev_dma_uninit(pdev); out_dma_init: spin_lock(&pci_lock); @@ -286,6 +285,8 @@ linux_pci_detach(device_t dev) pdev = device_get_softc(dev); pdev->pdrv->remove(pdev); + + free(pdev->bus, M_DEVBUF); linux_pdev_dma_uninit(pdev); spin_lock(&pci_lock);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905091023.x49ANgDw009962>