From: Prarit Bhargava <prarit@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Prarit Bhargava <prarit@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Wei Liu <wei.liu@kernel.org>,
Saurabh Sengar <ssengar@linux.microsoft.com>,
Johan Hovold <johan+linaro@kernel.org>,
Michael Kelley <mikelley@microsoft.com>,
David Malcolm <dmalcolm@redhat.com>,
David Arcari <darcari@redhat.com>,
Don Zickus <dzickus@redhat.com>
Subject: [PATCH] x86/ioapic: io_apic fix null dereference check
Date: Mon, 4 Dec 2023 13:02:26 -0500 [thread overview]
Message-ID: <20231204180226.383745-1-prarit@redhat.com> (raw)
The gcc plugin -fanalyzer [1] tries to detect various
patterns of incorrect behaviour. The tool reports
arch/x86/kernel/apic/io_apic.c: In function ‘ioapic_destroy_irqdomain’:
arch/x86/kernel/apic/io_apic.c:2390:12: warning: check of ‘ioapics[idx].irqdomain’ for NULL after already dereferencing it [-Wanalyzer-deref-before-check]
|
| 2388 | struct fwnode_handle *fn = ioapics[idx].irqdomain->fwnode;
| | ^~
| | |
| | (1) pointer ‘ioapics[idx].irqdomain’ is dereferenced here
| 2389 |
| 2390 | if (ioapics[idx].irqdomain) {
| | ~
| | |
| | (2) pointer ‘ioapics[idx].irqdomain’ is checked for NULL here but it was already dereferenced at (1)
|
Fix the null dereference check in ioapic_destroy_irqdomain().
[1] https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Static-Analyzer-Options.html
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@redhat.com>
CC: Borislav Petkov <bp@alien8.de>
CC: Dave Hansen <dave.hansen@linux.intel.com>
CC: x86@kernel.org
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: "Peter Zijlstra (Intel)" <peterz@infradead.org>
CC: Wei Liu <wei.liu@kernel.org>
CC: Prarit Bhargava <prarit@redhat.com>
CC: Saurabh Sengar <ssengar@linux.microsoft.com>
CC: Johan Hovold <johan+linaro@kernel.org>
CC: Michael Kelley <mikelley@microsoft.com>
CC: David Malcolm <dmalcolm@redhat.com>
CC: David Arcari <darcari@redhat.com>
CC: Don Zickus <dzickus@redhat.com>
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
---
arch/x86/kernel/apic/io_apic.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 00da6cf6b07d..f6f19eee0339 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -2381,14 +2381,14 @@ static int mp_irqdomain_create(int ioapic)
static void ioapic_destroy_irqdomain(int idx)
{
struct ioapic_domain_cfg *cfg = &ioapics[idx].irqdomain_cfg;
- struct fwnode_handle *fn = ioapics[idx].irqdomain->fwnode;
- if (ioapics[idx].irqdomain) {
- irq_domain_remove(ioapics[idx].irqdomain);
- if (!cfg->dev)
- irq_domain_free_fwnode(fn);
- ioapics[idx].irqdomain = NULL;
- }
+ if (!ioapics[idx].irqdomain)
+ return;
+
+ irq_domain_remove(ioapics[idx].irqdomain);
+ if (!cfg->dev)
+ irq_domain_free_fwnode(ioapics[idx].irqdomain->fwnode);
+ ioapics[idx].irqdomain = NULL;
}
void __init setup_IO_APIC(void)
--
2.43.0
reply other threads:[~2023-12-04 18:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20231204180226.383745-1-prarit@redhat.com \
--to=prarit@redhat.com \
--cc=bp@alien8.de \
--cc=darcari@redhat.com \
--cc=dave.hansen@linux.intel.com \
--cc=dmalcolm@redhat.com \
--cc=dzickus@redhat.com \
--cc=hpa@zytor.com \
--cc=johan+linaro@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikelley@microsoft.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=ssengar@linux.microsoft.com \
--cc=tglx@linutronix.de \
--cc=wei.liu@kernel.org \
--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
all inboxes | Powered by JetHome®