Hello, > Fixes an oops found while testing the stm32_pcie ep driver with handling > of PERST# deassertion: > > During EP initialization, pci_epf_test_alloc_space allocates all BARs, > which are further freed if epc_set_bar fails (for instance, due to > no free inbound window). > > However, when pci_epc_set_bar fails, the error path: > pci_epc_set_bar -> pci_epf_free_space > does not reset epf_test->reg[bar]. > > Then, if the host reboots, PERST# deassertion restarts the BAR allocation > sequence with the same allocation failure (no free inbound window), > creating a double free situation since epf_test->reg[bar] was deallocated > and is still non-NULL. > > Make sure that pci_epf_alloc_space/pci_epf_free_space are symmetric > by resetting epf_test->reg[bar] when memory is deallocated. Applied to endpoint, thank you! Krzysztof