brcm63xx: brcm63xxpart: fix buffer overrun in of parser
[openwrt/staging/lynxis/omap.git] / target / linux / brcm63xx / patches-3.14 / 425-bcm63xxpart_parse_paritions_from_dt.patch
index 7f3890eb0a717d566ba6cd7f256fe412e3d57b33..53fc4c5d23089fc902c27ba162b56e395c1d2f27 100644 (file)
                }
        } else {
                pr_warn("CFE boot tag CRC invalid (expected %08x, actual %08x)\n",
-@@ -139,16 +108,145 @@ static int bcm63xx_parse_cfe_partitions(
+@@ -139,16 +108,153 @@ static int bcm63xx_parse_cfe_partitions(
                kernellen = 0;
                rootfslen = 0;
                rootfsaddr = 0;
 +              if (node_has_compatible(pp))
 +                      continue;
 +
++              if (!of_get_property(pp, "reg", &len))
++                      continue;
++
++              partname = of_get_property(pp, "label", &len);
++              if (!partname)
++                      partname = of_get_property(pp, "name", &len);
++
++              if (!strcmp(partname, "linux"))
++                      nr_parts += 2;
++
 +              nr_parts++;
 +      }
 +
 +                      continue;
 +
 +              reg = of_get_property(pp, "reg", &len);
-+              if (!reg) {
-+                      nr_parts--;
++              if (!reg)
 +                      continue;
-+              }
 +
 +              a_cells = of_n_addr_cells(pp);
 +              s_cells = of_n_size_cells(pp);
  
        if (caldatalen1 > 0)
                nrparts++;
-@@ -158,10 +256,8 @@ static int bcm63xx_parse_cfe_partitions(
+@@ -158,10 +264,8 @@ static int bcm63xx_parse_cfe_partitions(
  
        /* Ask kernel for more memory */
        parts = kzalloc(sizeof(*parts) * nrparts + 10 * nrparts, GFP_KERNEL);
  
        /* Start building partition list */
        parts[curpart].name = "CFE";
-@@ -169,29 +265,7 @@ static int bcm63xx_parse_cfe_partitions(
+@@ -169,29 +273,7 @@ static int bcm63xx_parse_cfe_partitions(
        parts[curpart].size = cfelen;
        curpart++;
  
  
        if (caldatalen1 > 0) {
                if (caldatalen2 > 0)
-@@ -217,25 +291,33 @@ static int bcm63xx_parse_cfe_partitions(
+@@ -217,25 +299,33 @@ static int bcm63xx_parse_cfe_partitions(
  
        /* Global partition "linux" to make easy firmware upgrade */
        parts[curpart].name = "linux";