Blob Blame History Raw
From: Colin Ian King <colin.king@canonical.com>
Date: Mon, 6 Aug 2018 17:50:45 +0100
Subject: net: thunderx: check for failed allocation lmac->dmacs
Patch-mainline: v4.18
Git-commit: a94cead71c4651da5649134e3cdc29b1f32327a2
References: bsc#1110096

The allocation of lmac->dmacs is not being checked for allocation
failure. Add the check.

Fixes: 3a34ecfd9d3f ("net: thunderx: add MAC address filter tracking for LMAC")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -1066,6 +1066,8 @@ static int bgx_lmac_enable(struct bgx *b
 	lmac->dmacs_count = (RX_DMAC_COUNT / bgx->lmac_count);
 	lmac->dmacs = kcalloc(lmac->dmacs_count, sizeof(*lmac->dmacs),
 			      GFP_KERNEL);
+	if (!lmac->dmacs)
+		return -ENOMEM;
 
 	/* Enable lmac */
 	bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, CMR_EN);