Title: [6859] trunk/arch/blackfin/kernel/setup.c: Fix bug [#4536]
Revision
6859
Author
rgetz
Date
2009-06-26 07:23:51 -0500 (Fri, 26 Jun 2009)

Log Message

Fix bug [#4536]

Since the default MTD_UCLINUX has no magic number, we just blindly
read 8 past the end of the kernel's image, and look at it.
When no image is attached, mtd_size is set to a random number
Do some basic sanity checks before operating on things.

Modified Paths

Diff

Modified: trunk/arch/blackfin/kernel/setup.c (6858 => 6859)


--- trunk/arch/blackfin/kernel/setup.c	2009-06-26 00:50:18 UTC (rev 6858)
+++ trunk/arch/blackfin/kernel/setup.c	2009-06-26 12:23:51 UTC (rev 6859)
@@ -567,17 +567,23 @@
 #  endif				/* ANOMALY_05000263 */
 # endif				/* CONFIG_ROMFS_FS */
 
-	memory_end -= mtd_size;
+	/* Since the default MTD_UCLINUX has no magic number, we just blindly
+	 * read 8 past the end of the kernel's image, and look at it.
+	 * When no image is attached, mtd_size is set to a random number
+	 * Do some basic sanity checks before operating on things
+	 */
+	if (mtd_size == 0 || memory_end <= mtd_size) {
+		pr_emerg("Could not find valid ram mtd attached.\n");
+	} else {
+		memory_end -= mtd_size;
 
-	if (mtd_size == 0) {
-		console_init();
-		panic("Don't boot kernel without rootfs attached.");
+		/* Relocate MTD image to the top of memory after the uncached memory area */
+		uclinux_ram_map.phys = memory_mtd_start = memory_end;
+		uclinux_ram_map.size = mtd_size;
+		pr_info("Found mtd parition at 0x%p, (len=0x%lx), moving to 0x%p\n",
+			_end, mtd_size, (void *)memory_mtd_start);
+		dma_memcpy((void *)uclinux_ram_map.phys, _end, uclinux_ram_map.size);
 	}
-
-	/* Relocate MTD image to the top of memory after the uncached memory area */
-	uclinux_ram_map.phys = memory_mtd_start = memory_end;
-	uclinux_ram_map.size = mtd_size;
-	dma_memcpy((void *)uclinux_ram_map.phys, _end, uclinux_ram_map.size);
 #endif				/* CONFIG_MTD_UCLINUX */
 
 #if (defined(CONFIG_BFIN_EXTMEM_ICACHEABLE) && ANOMALY_05000263)
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to