Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 108ebcd8 authored by Rafał Miłecki's avatar Rafał Miłecki Committed by Brian Norris
Browse files

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: default avatarRafał Miłecki <zajec5@gmail.com>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent 00b79860
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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;