diff mbox series

x86/PCI: Remove unused assignment to variable info

Message ID 20210420210913.1137116-1-kw@linux.com
State New
Headers show
Series x86/PCI: Remove unused assignment to variable info | expand

Commit Message

Krzysztof Wilczyński April 20, 2021, 9:09 p.m. UTC
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")
Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
---
 arch/x86/pci/amd_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bjorn Helgaas April 30, 2021, 7:19 p.m. UTC | #1
On Tue, Apr 20, 2021 at 09:09:13PM +0000, Krzysztof Wilczyński wrote:
> 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")
> Signed-off-by: Krzysztof Wilczyński <kw@linux.com>

Applied to pci/misc for v5.13, thanks!

> ---
>  arch/x86/pci/amd_bus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
> index bfa50e65ef6c..ae744b6a0785 100644
> --- a/arch/x86/pci/amd_bus.c
> +++ b/arch/x86/pci/amd_bus.c
> @@ -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);
>  	}
>  
>  	/*
> -- 
> 2.31.0
>
diff mbox series

Patch

diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
index bfa50e65ef6c..ae744b6a0785 100644
--- a/arch/x86/pci/amd_bus.c
+++ b/arch/x86/pci/amd_bus.c
@@ -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);
 	}
 
 	/*