Skip to contentSkip to conversation

x86: io-apic - restore_IO_APIC_setup NULL pointer quick fix

PATCH In review Cyrill Gorcunov 2 participants 3 messages Sep 18, 2008 – Sep 19, 2008 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: io-apic - restore_IO_APIC_setup NULL pointer quick fix

Check if memory was granted first - we don't like NULL deref. It's a *quick* fix. Actually it's better to hadle this error at moment of memory allocation. It's save_mask_IO_APIC_setup route who allocates this memory (just for the record).

---

I'll handle this in _normal_ way tomorrow. Please review.

arch/x86/kernel/io_apic.c +5 -1
Index: linux-2.6.git/arch/x86/kernel/io_apic.c
===================================================================
@@ -852,10 +852,14 @@ void restore_IO_APIC_setup(void)
 {
 	int apic, pin;
 
-	for (apic = 0; apic < nr_ioapics; apic++)
+	for (apic = 0; apic < nr_ioapics; apic++) {
+		/* FIXME: it should be handled at allocation time --cvg */
+		if (!early_ioapic_entries[apic])
+			break;
 		for (pin = 0; pin < nr_ioapic_registers[apic]; pin++)
 			ioapic_write_entry(apic, pin,
 					   early_ioapic_entries[apic][pin]);
+	}
 }
 
 void reinit_intr_remapped_IO_APIC(int intr_remapping)
#1 lore raw
Quoted 9 lines · Cyrill Gorcunov

Check if memory was granted first - we don't like NULL deref. It's a *quick* fix. Actually it's better to hadle this error at moment of memory allocation. It's save_mask_IO_APIC_setup route who allocates this memory (just for the record).

---

I'll handle this in _normal_ way tomorrow. Please review.

ok, i've applied the quick fix to tip/master - the patch will drop from there on the next integration run.

Ingo

#2 lore raw

[Ingo Molnar - Fri, Sep 19, 2008 at 10:05:20AM +0200]

| 
| * Cyrill Gorcunov <[email protected]> wrote:
| 
| > Check if memory was granted first - we don't like NULL deref.
| > It's a *quick* fix. Actually it's better to hadle this error
| > at moment of memory allocation. It's save_mask_IO_APIC_setup
| > route who allocates this memory (just for the record).
| > 
| > Signed-off-by: Cyrill Gorcunov <[email protected]>
| > ---
| > 
| > I'll handle this in _normal_ way tomorrow. Please review.
| 
| ok, i've applied the quick fix to tip/master - the patch will drop from 
| there on the next integration run.
| 
| 	Ingo
| 

thanks Ingo, it seems there memory leak too. Handling...

- Cyrill -