dev/pci: Unmap memory on allocation failure

This commit is contained in:
2026-11-02 21:53:06 +01:00
committed by Marvin Friedrich
parent 54f279a9e6
commit fd50c97f1a
3 changed files with 24 additions and 4 deletions
+7 -1
View File
@@ -43,8 +43,14 @@ errno_t pci_ecam_register(phys_t base, uint16_t domain, uint8_t start_bus, uint8
for (size_t i = 0; i < length; i += arch_mem_page_size()) {
errno_t status = pmap_map(&kernel_vma.pmap, vaddr + i, phys + i, PTE_READ | PTE_WRITE, CACHE_MMIO);
if (status != 0)
if (status != 0) {
while (i) {
i -= arch_mem_page_size();
pmap_unmap(&kernel_vma.pmap, vaddr + i);
}
vm_free(vaddr, length);
return status;
}
}
struct pci_ecam* ecam = mem_alloc(sizeof(*ecam), 0);