0082-net-next-mediatek-add-missing-return-code-check.patch 959 B

1234567891011121314151617181920212223242526
  1. From 51ca1e9f141499fd7c95bff5401215b706656754 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <john@phrozen.org>
  3. Date: Sat, 23 Apr 2016 09:06:05 +0200
  4. Subject: [PATCH 082/102] 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: Sean Wang <keyhaede@gmail.com>
  8. Signed-off-by: John Crispin <john@phrozen.org>
  9. ---
  10. drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 +++
  11. 1 file changed, 3 insertions(+)
  12. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  13. +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  14. @@ -498,6 +498,9 @@ static int mtk_init_fq_dma(struct mtk_et
  15. eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE,
  16. GFP_KERNEL);
  17. + if (unlikely(!eth->scratch_head))
  18. + return -ENOMEM;
  19. +
  20. dma_addr = dma_map_single(eth->dev,
  21. eth->scratch_head, cnt * MTK_QDMA_PAGE_SIZE,
  22. DMA_FROM_DEVICE);