浏览代码

powerpc: Protect against NULL pointer deref in phyp-dump code

print_dump_header() will be called at least once with a NULL pointer in
a normal boot sequence.  If DEBUG is defined then we will dereference
the pointer and crash.  Add a quick fix to exit early in the NULL pointer
case.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Acked-by: Manish Ahuja <mahujam@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Tony Breeds 16 年之前
父节点
当前提交
7a2eab0d4e
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      arch/powerpc/platforms/pseries/phyp_dump.c

+ 3 - 0
arch/powerpc/platforms/pseries/phyp_dump.c

@@ -130,6 +130,9 @@ static unsigned long init_dump_header(struct phyp_dump_header *ph)
 static void print_dump_header(const struct phyp_dump_header *ph)
 static void print_dump_header(const struct phyp_dump_header *ph)
 {
 {
 #ifdef DEBUG
 #ifdef DEBUG
+	if (ph == NULL)
+		return;
+
 	printk(KERN_INFO "dump header:\n");
 	printk(KERN_INFO "dump header:\n");
 	/* setup some ph->sections required */
 	/* setup some ph->sections required */
 	printk(KERN_INFO "version = %d\n", ph->version);
 	printk(KERN_INFO "version = %d\n", ph->version);