net: thunderx: check for failed allocation lmac->dmacs
authorColin Ian King <colin.king@canonical.com>
Mon, 6 Aug 2018 16:50:45 +0000 (17:50 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 7 Aug 2018 19:38:13 +0000 (12:38 -0700)
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>
drivers/net/ethernet/cavium/thunder/thunder_bgx.c

index 5d08d2a..e337da6 100644 (file)
@@ -1083,6 +1083,8 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid)
        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);