diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2014-02-26 08:30:34 -0500 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2014-03-11 01:42:29 -0400 |
commit | 108ebcd81907cd4818feb3bc1eabcc4a5373da32 (patch) | |
tree | e69136542afe80e595d0d2d0a4668875d434cbea | |
parent | 00b79860eb5f72462016046d3841b19ebff6e846 (diff) |
mtd: bcm47xxpart: avoid overflowing when registering trx
Our code parsing "trx" header registers few partitions at once (in one
loop iteration). Add extra check in that place.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r-- | drivers/mtd/bcm47xxpart.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c index e388e69d853e..23d712209b98 100644 --- a/drivers/mtd/bcm47xxpart.c +++ b/drivers/mtd/bcm47xxpart.c | |||
@@ -147,6 +147,11 @@ static int bcm47xxpart_parse(struct mtd_info *master, | |||
147 | 147 | ||
148 | /* TRX */ | 148 | /* TRX */ |
149 | if (buf[0x000 / 4] == TRX_MAGIC) { | 149 | if (buf[0x000 / 4] == TRX_MAGIC) { |
150 | if (BCM47XXPART_MAX_PARTS - curr_part < 4) { | ||
151 | pr_warn("Not enough partitions left to register trx, scanning stopped!\n"); | ||
152 | break; | ||
153 | } | ||
154 | |||
150 | trx = (struct trx_header *)buf; | 155 | trx = (struct trx_header *)buf; |
151 | 156 | ||
152 | trx_part = curr_part; | 157 | trx_part = curr_part; |