From: Hauke Mehrtens Date: Sun, 13 Oct 2013 20:53:49 +0000 (+0200) Subject: mtd: bcm47xxpart: handle malloc failures X-Git-Tag: MMI-PSA29.97-13-9~13292^2~39 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=99b1d1887fee36ef9ff5d2ee24f0cf3e8c172104;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git mtd: bcm47xxpart: handle malloc failures Handle return NULL in malloc. Signed-off-by: Hauke Mehrtens Signed-off-by: Brian Norris --- diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c index 9279a9174f84..6d427468c4cd 100644 --- a/drivers/mtd/bcm47xxpart.c +++ b/drivers/mtd/bcm47xxpart.c @@ -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;