Skip to contentSkip to conversation

x86/PCI: Remove unused assignment to variable info

PATCH Applied Krzysztof Wilczyński 2 participants 2 messages Apr 20, 2021 – Apr 30, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index bfa50e65ef6c..ae744b6a0785 100644
@@ -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
#1 lore raw
Quoted 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 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.

Quoted 6 lines

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")

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
index bfa50e65ef6c..ae744b6a0785 100644
@@ -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