Skip to contentSkip to conversation

mtd: bcm47xxpart: avoid overflowing when registering trx

PATCH Applied Rafał Miłecki 2 participants 2 messages Feb 26, 2014 – Mar 7, 2014 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/mtd/bcm47xxpart.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mtd/bcm47xxpart.c +5 -0
index e388e69..23d7122 100644
@@ -147,6 +147,11 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 
 		/* TRX */
 		if (buf[0x000 / 4] == TRX_MAGIC) {
+			if (BCM47XXPART_MAX_PARTS - curr_part < 4) {
+				pr_warn("Not enough partitions left to register trx, scanning stopped!\n");
+				break;
+			}
+
 			trx = (struct trx_header *)buf;
 
 			trx_part = curr_part;
Signature · 1 line
1.8.4.5
Applied
#1 lore raw
Quoted 4 lines · Rafał Miłecki

Our code parsing "trx" header registers few partitions at once (in one loop iteration). Add extra check in that place.

Pushed to l2-mtd.git. Thanks!

Brian