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

Commit 99b1d188 authored by Hauke Mehrtens's avatar Hauke Mehrtens Committed by Brian Norris
Browse files

mtd: bcm47xxpart: handle malloc failures



Handle return NULL in malloc.

Signed-off-by: default avatarHauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent 7e3019e3
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -71,7 +71,14 @@ static int bcm47xxpart_parse(struct mtd_info *master,
	/* Alloc */
	parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS,
			GFP_KERNEL);
	if (!parts)
		return -ENOMEM;

	buf = kzalloc(BCM47XXPART_BYTES_TO_READ, GFP_KERNEL);
	if (!buf) {
		kfree(parts);
		return -ENOMEM;
	}

	/* Parse block by block looking for magics */
	for (offset = 0; offset <= master->size - blocksize;