652001ecf97bc3d416037b1472cd587278226324
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.4 / 0083-net-next-mediatek-add-missing-return-code-check.patch
1 From d20b45f50d6b3352aa7be76eb7a28cffcfe379da Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sat, 23 Apr 2016 09:06:05 +0200
4 Subject: [PATCH 83/91] net-next: mediatek: add missing return code check
5
6 The code fails to check if the scratch memory was properly allocated. Add
7 this check and return with an error if the allocation failed.
8
9 Signed-off-by: John Crispin <blogic@openwrt.org>
10 ---
11 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 +++
12 1 file changed, 3 insertions(+)
13
14 diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
15 index aa25788..e58a634 100644
16 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
17 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
18 @@ -483,6 +483,9 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
19
20 eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE,
21 GFP_KERNEL);
22 + if (unlikely(!eth->scratch_head))
23 + return -ENOMEM;
24 +
25 dma_addr = dma_map_single(eth->dev,
26 eth->scratch_head, cnt * MTK_QDMA_PAGE_SIZE,
27 DMA_FROM_DEVICE);
28 --
29 1.7.10.4
30