Browse Source

mtd: bcm47xxpart: only register partitions if the trx header was filled

Sometimes the trx offsets are 0, in that case there is no partition and
we should not try to add one.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
[Brian: rewrapped]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Hauke Mehrtens 11 years ago
parent
commit
a1ff7d64c5
1 changed files with 14 additions and 6 deletions
  1. 14 6
      drivers/mtd/bcm47xxpart.c

+ 14 - 6
drivers/mtd/bcm47xxpart.c

@@ -172,18 +172,26 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 				i++;
 				i++;
 			}
 			}
 
 
-			bcm47xxpart_add_part(&parts[curr_part++], "linux",
-					     offset + trx->offset[i], 0);
-			i++;
+			if (trx->offset[i]) {
+				bcm47xxpart_add_part(&parts[curr_part++],
+						     "linux",
+						     offset + trx->offset[i],
+						     0);
+				i++;
+			}
 
 
 			/*
 			/*
 			 * Pure rootfs size is known and can be calculated as:
 			 * Pure rootfs size is known and can be calculated as:
 			 * trx->length - trx->offset[i]. We don't fill it as
 			 * trx->length - trx->offset[i]. We don't fill it as
 			 * we want to have jffs2 (overlay) in the same mtd.
 			 * we want to have jffs2 (overlay) in the same mtd.
 			 */
 			 */
-			bcm47xxpart_add_part(&parts[curr_part++], "rootfs",
-					     offset + trx->offset[i], 0);
-			i++;
+			if (trx->offset[i]) {
+				bcm47xxpart_add_part(&parts[curr_part++],
+						     "rootfs",
+						     offset + trx->offset[i],
+						     0);
+				i++;
+			}
 
 
 			last_trx_part = curr_part - 1;
 			last_trx_part = curr_part - 1;