Skip to content

Commit f126598

Browse files
committed
x86/pci: Return pci_mmconfig_add() failure early
If pci_mmconfig_alloc() fails, return the failure early so it's obvious that the failure is the exception, and the success is the normal case. No functional change intended. Link: https://lore.kernel.org/r/[email protected] Tested-by: Tomasz Pala <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent f284dff commit f126598

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

arch/x86/pci/mmconfig-shared.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,15 @@ struct pci_mmcfg_region *__init pci_mmconfig_add(int segment, int start,
102102
struct pci_mmcfg_region *new;
103103

104104
new = pci_mmconfig_alloc(segment, start, end, addr);
105-
if (new) {
106-
mutex_lock(&pci_mmcfg_lock);
107-
list_add_sorted(new);
108-
mutex_unlock(&pci_mmcfg_lock);
105+
if (!new)
106+
return NULL;
109107

110-
pr_info("ECAM %pR (base %#lx) for domain %04x [bus %02x-%02x]\n",
111-
&new->res, (unsigned long)addr, segment, start, end);
112-
}
108+
mutex_lock(&pci_mmcfg_lock);
109+
list_add_sorted(new);
110+
mutex_unlock(&pci_mmcfg_lock);
111+
112+
pr_info("ECAM %pR (base %#lx) for domain %04x [bus %02x-%02x]\n",
113+
&new->res, (unsigned long)addr, segment, start, end);
113114

114115
return new;
115116
}

0 commit comments

Comments
 (0)