Root/target/linux/atheros/patches-3.3/141-redboot_partition_scan.patch

1--- a/drivers/mtd/redboot.c
2+++ b/drivers/mtd/redboot.c
3@@ -79,6 +79,11 @@ static int parse_redboot_partitions(stru
4     static char nullstring[] = "unallocated";
5 #endif
6 
7+ buf = vmalloc(master->erasesize);
8+ if (!buf)
9+ return -ENOMEM;
10+
11+ restart:
12     if ( directory < 0 ) {
13         offset = master->size + directory * master->erasesize;
14         while (mtd_can_have_bb(master) &&
15@@ -86,6 +91,7 @@ static int parse_redboot_partitions(stru
16             if (!offset) {
17             nogood:
18                 printk(KERN_NOTICE "Failed to find a non-bad block to check for RedBoot partition table\n");
19+ vfree(buf);
20                 return -EIO;
21             }
22             offset -= master->erasesize;
23@@ -99,10 +105,6 @@ static int parse_redboot_partitions(stru
24                 goto nogood;
25         }
26     }
27- buf = vmalloc(master->erasesize);
28-
29- if (!buf)
30- return -ENOMEM;
31 
32     printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n",
33            master->name, offset);
34@@ -175,6 +177,11 @@ static int parse_redboot_partitions(stru
35     }
36     if (i == numslots) {
37         /* Didn't find it */
38+ if (offset + master->erasesize < master->size) {
39+ /* not at the end of the flash yet, maybe next block :) */
40+ directory++;
41+ goto restart;
42+ }
43         printk(KERN_NOTICE "No RedBoot partition table detected in %s\n",
44                master->name);
45         ret = 0;
46

Archive Download this file



interactive