diff options
-rw-r--r-- | drivers/mtd/bcm47xxpart.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c index e06d782489a6..06125eb59f14 100644 --- a/drivers/mtd/bcm47xxpart.c +++ b/drivers/mtd/bcm47xxpart.c | |||
@@ -169,11 +169,12 @@ static int bcm47xxpart_parse(struct mtd_info *master, | |||
169 | * Assume that partitions end at the beginning of the one they are | 169 | * Assume that partitions end at the beginning of the one they are |
170 | * followed by. | 170 | * followed by. |
171 | */ | 171 | */ |
172 | for (i = 0; i < curr_part - 1; i++) | 172 | for (i = 0; i < curr_part; i++) { |
173 | parts[i].size = parts[i + 1].offset - parts[i].offset; | 173 | u64 next_part_offset = (i < curr_part - 1) ? |
174 | if (curr_part > 0) | 174 | parts[i + 1].offset : master->size; |
175 | parts[curr_part - 1].size = | 175 | |
176 | master->size - parts[curr_part - 1].offset; | 176 | parts[i].size = next_part_offset - parts[i].offset; |
177 | } | ||
177 | 178 | ||
178 | *pparts = parts; | 179 | *pparts = parts; |
179 | return curr_part; | 180 | return curr_part; |