summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mediatek
diff options
context:
space:
mode:
authorJohn Crispin <john@phrozen.org>2016-06-10 13:27:58 +0200
committerDavid S. Miller <davem@davemloft.net>2016-06-10 23:29:28 -0700
commit562c5a70400c75f50d99de631666ac7cc2f03958 (patch)
tree35ece322f036c00f23f7038088e4e51651f5f87b /drivers/net/ethernet/mediatek
parent0b392be9a86560dae3af2e7528f226ff465ab549 (diff)
downloadlinux-562c5a70400c75f50d99de631666ac7cc2f03958.tar.bz2
net: mediatek: add missing return code check
The code fails to check if the scratch memory was properly allocated. Add this check and return with an error if the allocation failed. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mediatek')
-rw-r--r--drivers/net/ethernet/mediatek/mtk_eth_soc.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 4763252bbf85..11cd7304e497 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -495,6 +495,9 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE,
GFP_KERNEL);
+ if (unlikely(!eth->scratch_head))
+ return -ENOMEM;
+
dma_addr = dma_map_single(eth->dev,
eth->scratch_head, cnt * MTK_QDMA_PAGE_SIZE,
DMA_FROM_DEVICE);