linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Armin Steinhoff <armin@steinhoff.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	linux-rt-users <linux-rt-users@vger.kernel.org>,
	x86@kernel.org
Subject: Re: io_apic.c --> "nr_ioapics" not initialized !
Date: Wed, 20 Feb 2013 23:55:01 +0100 (CET)	[thread overview]
Message-ID: <alpine.LFD.2.02.1302202336270.22263@ionos> (raw)
In-Reply-To: <5124F7BA.5080905@steinhoff.de>

On Wed, 20 Feb 2013, Armin Steinhoff wrote:
> after a walk through the module "io_apic.c" in
> "/usr/src/linux/arch/x86/kernel/apic" I got the impression that the variable
> "nr_ioapics" is used but isn't initialized !
> Could it be the source of boot problems ?

Well no, unless your compiler is silly.
 
arch/x86/kernel/apic/io_apic.c:int nr_ioapics;

That's initialized to 0

> Dangerous coding stile in "static struct resource * __init
> ioapic_setup_resources(int nr_ioapics)" ....

Though the brilliant brain who decided to name the argument of
ioapic_setup_resources() the same as a global variable and of course
the call site of it to do:

    ioapic_res = ioapic_setup_resources(nr_ioapics);

Brilliant. Unfortunately that's completely correct C code. Though it's
confusing as hell and definitely worth to be fixed. Patch below.

Thanks,

	tglx

Index: linux-2.6/arch/x86/kernel/apic/io_apic.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/apic/io_apic.c
+++ linux-2.6/arch/x86/kernel/apic/io_apic.c
@@ -3637,25 +3637,25 @@ void __init setup_ioapic_dest(void)
 
 static struct resource *ioapic_resources;
 
-static struct resource * __init ioapic_setup_resources(int nr_ioapics)
+static struct resource * __init ioapic_setup_resources(int cnt)
 {
 	unsigned long n;
 	struct resource *res;
 	char *mem;
 	int i;
 
-	if (nr_ioapics <= 0)
+	if (cnt <= 0)
 		return NULL;
 
 	n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource);
-	n *= nr_ioapics;
+	n *= cnt;
 
 	mem = alloc_bootmem(n);
 	res = (void *)mem;
 
-	mem += sizeof(struct resource) * nr_ioapics;
+	mem += sizeof(struct resource) * cnt;
 
-	for (i = 0; i < nr_ioapics; i++) {
+	for (i = 0; i < cnt; i++) {
 		res[i].name = mem;
 		res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY;
 		snprintf(mem, IOAPIC_RESOURCE_NAME_SIZE, "IOAPIC %u", i);

  parent reply	other threads:[~2013-02-20 22:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-19  3:56 [PATCH RT 0/7] [ANNOUNCE] 3.2.38-rt58-rc1 stable review Steven Rostedt
2013-02-19  3:56 ` [PATCH RT 1/7] x86/32: Use kmap switch for non highmem as well Steven Rostedt
2013-02-19  3:56 ` [PATCH RT 2/7] acpi/rt: Convert acpi_gbl_hardware lock back to a raw_spinlock_t Steven Rostedt
2013-02-19  3:56 ` [PATCH RT 3/7] printk: Fix rq->lock vs logbuf_lock unlock lock inversion Steven Rostedt
2013-02-19  3:56 ` [PATCH RT 4/7] serial: Imx: Fix recursive locking bug Steven Rostedt
2013-02-19  3:56 ` [PATCH RT 5/7] wait-simple: Simple waitqueue implementation Steven Rostedt
2013-02-19  3:56 ` [PATCH RT 6/7] rcutiny: Use simple waitqueue Steven Rostedt
2013-02-20 16:20   ` io_apic.c --> "nr_ioapics" not initialized ! Armin Steinhoff
2013-02-20 21:04     ` Robin Holt
2013-02-20 22:55     ` Thomas Gleixner [this message]
2013-02-21  7:30       ` Armin Steinhoff
2013-02-19  3:56 ` [PATCH RT 7/7] Linux 3.2.38-rt58-rc1 Steven Rostedt

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=alpine.LFD.2.02.1302202336270.22263@ionos \
    --to=tglx@linutronix.de \
    --cc=armin@steinhoff.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.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;
as well as URLs for NNTP newsgroup(s).