kernel: update 3.14 to 3.14.30
[openwrt.git] / target / linux / generic / patches-3.14 / 048-mtd-bcm47xxpart-backports-from-3.16.patch
1 --- a/drivers/mtd/Kconfig
2 +++ b/drivers/mtd/Kconfig
3 @@ -150,7 +150,7 @@ config MTD_BCM63XX_PARTS
4  
5  config MTD_BCM47XX_PARTS
6         tristate "BCM47XX partitioning support"
7 -       depends on BCM47XX
8 +       depends on BCM47XX || ARCH_BCM_5301X
9         help
10           This provides partitions parser for devices based on BCM47xx
11           boards.
12 --- a/drivers/mtd/bcm47xxpart.c
13 +++ b/drivers/mtd/bcm47xxpart.c
14 @@ -14,7 +14,6 @@
15  #include <linux/slab.h>
16  #include <linux/mtd/mtd.h>
17  #include <linux/mtd/partitions.h>
18 -#include <bcm47xx_nvram.h>
19  
20  /* 10 parts were found on sflash on Netgear WNDR4500 */
21  #define BCM47XXPART_MAX_PARTS          12
22 @@ -30,6 +29,7 @@
23  #define BOARD_DATA_MAGIC2              0xBD0D0BBD
24  #define CFE_MAGIC                      0x43464531      /* 1EFC */
25  #define FACTORY_MAGIC                  0x59544346      /* FCTY */
26 +#define NVRAM_HEADER                   0x48534C46      /* FLSH */
27  #define POT_MAGIC1                     0x54544f50      /* POTT */
28  #define POT_MAGIC2                     0x504f          /* OP */
29  #define ML_MAGIC1                      0x39685a42
30 @@ -91,7 +91,7 @@ static int bcm47xxpart_parse(struct mtd_
31                 if (offset >= 0x2000000)
32                         break;
33  
34 -               if (curr_part > BCM47XXPART_MAX_PARTS) {
35 +               if (curr_part >= BCM47XXPART_MAX_PARTS) {
36                         pr_warn("Reached maximum number of partitions, scanning stopped!\n");
37                         break;
38                 }
39 @@ -147,6 +147,11 @@ static int bcm47xxpart_parse(struct mtd_
40  
41                 /* TRX */
42                 if (buf[0x000 / 4] == TRX_MAGIC) {
43 +                       if (BCM47XXPART_MAX_PARTS - curr_part < 4) {
44 +                               pr_warn("Not enough partitions left to register trx, scanning stopped!\n");
45 +                               break;
46 +                       }
47 +
48                         trx = (struct trx_header *)buf;
49  
50                         trx_part = curr_part;
51 @@ -212,7 +217,7 @@ static int bcm47xxpart_parse(struct mtd_
52  
53         /* Look for NVRAM at the end of the last block. */
54         for (i = 0; i < ARRAY_SIZE(possible_nvram_sizes); i++) {
55 -               if (curr_part > BCM47XXPART_MAX_PARTS) {
56 +               if (curr_part >= BCM47XXPART_MAX_PARTS) {
57                         pr_warn("Reached maximum number of partitions, scanning stopped!\n");
58                         break;
59                 }