141-redboot_partition_scan.patch 1.1 KB

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