[PATCH] ppc64: fix nvram partition scan
Utz Bacher
utz.bacher at de.ibm.com
Mon Feb 28 12:59:15 EST 2005
Hi Paul and all,
the following patch against 2.6.11-rc4 corrects some problems with bad NVRAM
contents:
- when the checksum is incorrect, better do not trust anything (instead
of assuming the length is correct)
- when the partition length is zero, stop looking for more partitions
instead of looping
Please consider for inclusion.
Regards,
Utz
Signed-off-by: Utz Bacher <utz.bacher at de.ibm.com>
Index: linux-2.6.11-rc4/arch/ppc64/kernel/nvram.c
===================================================================
--- linux-2.6.11-rc4.orig/arch/ppc64/kernel/nvram.c
+++ linux-2.6.11-rc4/arch/ppc64/kernel/nvram.c
@@ -535,9 +535,21 @@
memcpy(&phead, header, NVRAM_HEADER_LEN);
c_sum = nvram_checksum(&phead);
- if (c_sum != phead.checksum)
- printk(KERN_WARNING "WARNING: nvram partition checksum "
- "was %02x, should be %02x!\n", phead.checksum, c_sum);
+ if (c_sum != phead.checksum) {
+ printk(KERN_WARNING "WARNING: nvram partition "
+ "checksum was %02x, should be %02x! Skipping "
+ "subsequent partitions to prevent data loss\n",
+ phead.checksum, c_sum);
+ kfree(header);
+ return size;
+ }
+
+ if (!phead.length) {
+ printk(KERN_WARNING "nvram partition chain ends "
+ "(zero partition length). Assuming end "
+ "of chain.\n");
+ break;
+ }
tmp_part = (struct nvram_partition *)
kmalloc(sizeof(struct nvram_partition), GFP_KERNEL);
More information about the Linuxppc64-dev
mailing list