Skip to contentSkip to conversation

s390: kmalloc failure ignored in smp_get_save_area()

PATCH Heiko Carstens 1 participant 1 message Sep 11, 2009 1 message not in the archive s390

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 11 lines · Roel Kluin

Prevent NULL dereference if kmalloc() fails.

---
Found with sed: http://kernelnewbies.org/roelkluin

arch/s390/kernel/smp.c +0 -0
index be2cae0..dfeac28 100644

arch/s390/kernel/smp.c static void __init smp_get_save_area(unsigned int cpu, unsigned int phy_cpu) · line 251

Quoted 5 lines
arch/s390/kernel/smp.c +2 -0
@@ -247,6 +247,8 @@ static void __init smp_get_save_area(unsigned int cpu, unsigned int phy_cpu)
 		return;
 	}
 	zfcpdump_save_areas[cpu] = kmalloc(sizeof(union save_area), GFP_KERNEL);
+	if (zfcpdump_save_areas[cpu] == NULL)
+		return;

If that allocation would fail that early in the boot process the only sane answer would be panic().
But if that allocation would fail the system is useless anyway so it really doesn't matter if we have a NULL pointer dereference just a few lines below. The result would be the same ;)