0083-net-next-mediatek-add-missing-return-code-check.patch 1.0 KB

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