net: fm: Fix a memory leak issue
authorHou Zhiqiang <Zhiqiang.Hou@nxp.com>
Wed, 2 Jun 2021 05:28:52 +0000 (13:28 +0800)
committerPriyanka Jain <priyanka.jain@nxp.com>
Mon, 7 Jun 2021 11:25:32 +0000 (16:55 +0530)
Fix a memory leak issue in the RX port initialization.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
drivers/net/fm/eth.c

index 0e89e66..7c23ccc 100644 (file)
@@ -288,8 +288,10 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 
        /* alloc Rx buffer from main memory */
        rx_buf_pool = malloc(MAX_RXBUF_LEN * RX_BD_RING_SIZE);
-       if (!rx_buf_pool)
+       if (!rx_buf_pool) {
+               free(rx_bd_ring_base);
                return -ENOMEM;
+       }
 
        memset(rx_buf_pool, 0, MAX_RXBUF_LEN * RX_BD_RING_SIZE);
        debug("%s: rx_buf_pool = %p\n", __func__, rx_buf_pool);