OSDN Git Service

kernel: bump 5.15 to 5.15.32
[immortalwrt/immortalwrt.git] / target / linux / ath79 / patches-5.15 / 408-mtd-redboot_partition_scan.patch
1 --- a/drivers/mtd/parsers/redboot.c
2 +++ b/drivers/mtd/parsers/redboot.c
3 @@ -90,12 +90,18 @@ static int parse_redboot_partitions(stru
4  
5         parse_redboot_of(master);
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_block_isbad(master, offset)) {
15                         if (!offset) {
16  nogood:
17                                 pr_notice("Failed to find a non-bad block to check for RedBoot partition table\n");
18 +                               vfree(buf);
19                                 return -EIO;
20                         }
21                         offset -= master->erasesize;
22 @@ -108,10 +114,6 @@ nogood:
23                                 goto nogood;
24                 }
25         }
26 -       buf = vmalloc(master->erasesize);
27 -
28 -       if (!buf)
29 -               return -ENOMEM;
30  
31         pr_notice("Searching for RedBoot partition table in %s at offset 0x%lx\n",
32                   master->name, offset);
33 @@ -183,6 +185,12 @@ nogood:
34         }
35         if (i == numslots) {
36                 /* Didn't find it */
37 +               if (offset + master->erasesize < master->size) {
38 +                       /* not at the end of the flash yet, maybe next block :) */
39 +                       directory++;
40 +                       goto restart;
41 +               }
42 +
43                 pr_notice("No RedBoot partition table detected in %s\n",
44                           master->name);
45                 ret = 0;