From: Rafał Miłecki Date: Wed, 26 Feb 2014 13:30:34 +0000 (+0100) Subject: mtd: bcm47xxpart: avoid overflowing when registering trx X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=108ebcd81907cd4818feb3bc1eabcc4a5373da32;p=openwrt%2Fstaging%2Fblogic.git 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 Signed-off-by: Brian Norris --- 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, /* 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;