408-mtd-redboot_partition_scan.patch 1.2 KB

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