From: Bjorn Helgaas <helgaas@kernel.org>
To: "Krzysztof Wilczyński" <kw@linux.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH] x86/PCI: Remove unused assignment to variable info
Date: Fri, 30 Apr 2021 14:19:12 -0500 [thread overview]
Message-ID: <20210430191912.GA673690@bjorn-Precision-5520> (raw)
In-Reply-To: <20210420210913.1137116-1-kw@linux.com>
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
>
prev parent reply other threads:[~2021-04-30 19:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-20 21:09 [PATCH] x86/PCI: Remove unused assignment to variable info Krzysztof Wilczyński
2021-04-30 19:19 ` Bjorn Helgaas [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210430191912.GA673690@bjorn-Precision-5520 \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=kw@linux.com \
--cc=linux-pci@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox