mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-16 10:20:30 +00:00
Fix memory leak of PCI BUS structure in the LinuxKPI.
MFC after: 1 week Sponsored by: Mellanox Technologies
This commit is contained in:
parent
eb6f534241
commit
e2eb11e577
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=347387
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user