From 5b2c9a6ce3ce66796e8c375133da8340c7ab2adc Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 13 Jun 2018 15:20:35 +0200 Subject: [PATCH] net: gem: Check return value from memalign/malloc Functions can return NULL in case of error that's why checking return value is needed. Signed-off-by: Michal Simek Acked-by: Joe Hershberger --- drivers/net/zynq_gem.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index 14564e365e..a817f2e5d6 100644 --- a/drivers/net/zynq_gem.c +++ b/drivers/net/zynq_gem.c @@ -633,10 +633,16 @@ static int zynq_gem_probe(struct udevice *dev) /* Align rxbuffers to ARCH_DMA_MINALIGN */ priv->rxbuffers = memalign(ARCH_DMA_MINALIGN, RX_BUF * PKTSIZE_ALIGN); + if (!priv->rxbuffers) + return -ENOMEM; + memset(priv->rxbuffers, 0, RX_BUF * PKTSIZE_ALIGN); /* Align bd_space to MMU_SECTION_SHIFT */ bd_space = memalign(1 << MMU_SECTION_SHIFT, BD_SPACE); + if (!bd_space) + return -ENOMEM; + mmu_set_region_dcache_behaviour((phys_addr_t)bd_space, BD_SPACE, DCACHE_OFF); -- 2.25.1