Skip to content

Commit

Permalink
bus/pci: free remaining devices during cleanup
Browse files Browse the repository at this point in the history
Devices can end up without driver assigned after
probing. The cleanup function from patch below does
not free devices that do not have it assigned.
The devices reported to leak are not the ones that
are the object of the hotplug test.

This issue appears only when using shared objects
build, and on a specific set of CI machines.
More debugging needs to happen to fully understand
the issue here.

Fixes patch below:
(1cab1a4)bus: cleanup devices on shutdown

Errors from ASAN:
00:16:25.099  ==48971==ERROR: LeakSanitizer: detected memory leaks
00:16:25.099
00:16:25.099  Indirect leak of 11544 byte(s) in 37 object(s) allocated
from:
00:16:25.099      #0 0x7f4d00f1a6af in __interceptor_malloc
(/usr/lib64/libasan.so.8+0xba6af)
00:16:25.099      #1 0x7f4d0017c4a7 in pci_scan_one
../drivers/bus/pci/linux/pci.c:218
00:16:25.099      #2 0x7f4d0017ceb5 in rte_pci_scan
../drivers/bus/pci/linux/pci.c:471
00:16:25.099      #3 0x7f4d0002394c in rte_bus_scan
../lib/eal/common/eal_common_bus.c:56
00:16:25.099      #4 0x7f4d00053847 in rte_eal_init
../lib/eal/linux/eal.c:1065
00:16:25.099      #5 0x7f4d00256c01 in spdk_env_init
/var/jenkins/workspace/hw-nvme-hotplug/spdk/lib/env_dpdk/init.c:585
00:16:25.099      #6 0x40709c in main
/var/jenkins/workspace/hw-nvme-hotplug/spdk/examples/nvme/hotplug/hotplug.c:571
00:16:25.099      #7 0x7f4cff50150f in __libc_start_call_main
(/usr/lib64/libc.so.6+0x2750f)

Change-Id: I78252587a0930a15097ce16227a4935d34871b75
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/dpdk/+/16443
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
  • Loading branch information
KKaras169169 authored and tomzawadzki committed Jan 24, 2023
1 parent fb2ae33 commit e89c084
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions drivers/bus/pci/pci_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,12 @@ pci_cleanup(void)
struct rte_pci_driver *drv = dev->driver;
int ret = 0;

if (drv == NULL || drv->remove == NULL)
continue;

ret = drv->remove(dev);
if (ret < 0) {
rte_errno = errno;
error = -1;
if (drv != NULL && drv->remove != NULL) {
ret = drv->remove(dev);
if (ret < 0) {
rte_errno = errno;
error = -1;
}
}
dev->driver = NULL;
dev->device.driver = NULL;
Expand Down

0 comments on commit e89c084

Please sign in to comment.