Sfoglia il codice sorgente

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>
John Crispin 9 anni fa
parent
commit
562c5a7040
1 ha cambiato i file con 3 aggiunte e 0 eliminazioni
  1. 3 0
      drivers/net/ethernet/mediatek/mtk_eth_soc.c

+ 3 - 0
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,
 	eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE,
 				    GFP_KERNEL);
 				    GFP_KERNEL);
+	if (unlikely(!eth->scratch_head))
+		return -ENOMEM;
+
 	dma_addr = dma_map_single(eth->dev,
 	dma_addr = dma_map_single(eth->dev,
 				  eth->scratch_head, cnt * MTK_QDMA_PAGE_SIZE,
 				  eth->scratch_head, cnt * MTK_QDMA_PAGE_SIZE,
 				  DMA_FROM_DEVICE);
 				  DMA_FROM_DEVICE);