x86/PCI: Remove unused assignment to variable info
PATCH 1/1 x86/PCI: Remove unused assignment to variable info
The value returned from the alloc_pci_root_info() function that is assigned to the "info" variable within the loop body is never used for anything once the loop finishes its run, and it is overridden later within another loop body where the value returned from the find_pci_root_info() will be assigned to it.
When the function alloc_pci_root_info() is executed within the body of the first loop, it would allocate a new struct pci_root_info and then store pointer to it in a global linked list called "pci_root_infos", thus the value that the "info" variable would contain after the loop finishes would reference the struct pci_root_info that was allocated the last, thus it might not necessarily be of use.
Additionally, the function find_pci_root_info() can be used to find and retrieve the relevant pci_root_info stored on the aforementioned linked list.
Since the value of the "info" variable following the first loop is never used in any meaningful way the assigned can be removed.
Related:
commit d28e5ac2a07e ("x86/PCI: dynamically allocate pci_root_info for native host bridge drivers") commit a10bb128b64f ("x86/PCI: put busn resource in pci_root_info for native host bridge drivers")
Addresses-Coverity-ID: 1222153 ("Unused value")
--- arch/x86/pci/amd_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/pci/amd_bus.c +1 -1
@@ -126,7 +126,7 @@ static int __init early_root_info_init(void) node = (reg >>4 ) &0x07 ; link = (reg >>8 ) &0x03 ; - info =alloc_pci_root_info (min_bus, max_bus, node, link); +alloc_pci_root_info (min_bus, max_bus, node, link); }/*
Signature · 1 line
2.31.0
Bjorn Helgaas
AppliedQuoted 20 lines · Krzysztof Wilczyński
The value returned from the
alloc_pci_root_info()function that is assigned to the "info" variable within the loop body is never used for anything once the loop finishes its run, and it is overridden later within another loop body where the value returned from thefind_pci_root_info()will be assigned to it.When the function
alloc_pci_root_info()is executed within the body of the first loop, it would allocate a new structpci_root_infoand then store pointer to it in a global linked list called "pci_root_infos", thus the value that the "info" variable would contain after the loop finishes would reference the structpci_root_infothat was allocated the last, thus it might not necessarily be of use.Additionally, the function
find_pci_root_info()can be used to find and retrieve the relevantpci_root_infostored on the aforementioned linked list.Since the value of the "info" variable following the first loop is never used in any meaningful way the assigned can be removed.
Quoted 6 lines
Related:
commitd28e5ac2a07e("x86/PCI: dynamically allocatepci_root_infofor native host bridge drivers") commita10bb128b64f("x86/PCI: put busn resource inpci_root_infofor native host bridge drivers")Addresses-Coverity-ID: 1222153 ("Unused value")
Signed-off-by Krzysztof Wilczyński <[email protected]>
Applied to pci/misc for v5.13, thanks!
Quoted 20 lines
--- arch/x86/pci/amd_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/pci/amd_bus.c +1
-1@@ -126,7 +126,7 @@ static int __init early_root_info_init(void) node = (reg >>4 ) &0x07 ; link = (reg >>8 ) &0x03 ; - info =alloc_pci_root_info (min_bus, max_bus, node, link); +alloc_pci_root_info (min_bus, max_bus, node, link); }/* Signature · 1 line
2.31.0