bcm53xx: 3.18: add early support for Buffalo WZR-900DHP
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.10 / 020-mtd-bcm47xxpart-handle-malloc-failures.patch
1 From 99b1d1887fee36ef9ff5d2ee24f0cf3e8c172104 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sun, 13 Oct 2013 22:53:49 +0200
4 Subject: [PATCH] mtd: bcm47xxpart: handle malloc failures
5
6 Handle return NULL in malloc.
7
8 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
9 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
10 ---
11 drivers/mtd/bcm47xxpart.c | 7 +++++++
12 1 file changed, 7 insertions(+)
13
14 --- a/drivers/mtd/bcm47xxpart.c
15 +++ b/drivers/mtd/bcm47xxpart.c
16 @@ -71,7 +71,14 @@ static int bcm47xxpart_parse(struct mtd_
17 /* Alloc */
18 parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS,
19 GFP_KERNEL);
20 + if (!parts)
21 + return -ENOMEM;
22 +
23 buf = kzalloc(BCM47XXPART_BYTES_TO_READ, GFP_KERNEL);
24 + if (!buf) {
25 + kfree(parts);
26 + return -ENOMEM;
27 + }
28
29 /* Parse block by block looking for magics */
30 for (offset = 0; offset <= master->size - blocksize;