[PATCH 1/8] net: mrmac: check memalign() return values

Padmarao Begari <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <[email protected]>
The memalign() allocations in probe() are used without checking for
failure. Bail out with -ENOMEM if any of them fails.

Fixes: 258ce79cfce4 ("net: xilinx: axi_mrmac: Add MRMAC driver")
Signed-off-by: Padmarao Begari <[email protected]>
---
 drivers/net/xilinx_axi_mrmac.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/xilinx_axi_mrmac.c b/drivers/net/xilinx_axi_mrmac.c
index 56f877c20a6..5ff304fc971 100644
--- a/drivers/net/xilinx_axi_mrmac.c
+++ b/drivers/net/xilinx_axi_mrmac.c
@@ -484,14 +484,20 @@ static int axi_mrmac_probe(struct udevice *dev)
 
 	/* Align buffers to ARCH_DMA_MINALIGN */
 	priv->tx_bd[0] = memalign(ARCH_DMA_MINALIGN, TX_BD_TOTAL_SIZE);
+	if (!priv->tx_bd[0])
+		return -ENOMEM;
 	priv->tx_bd[1] = (struct mcdma_bd *)((ulong)priv->tx_bd[0] +
 					     sizeof(struct mcdma_bd));
 
 	priv->rx_bd[0] = memalign(ARCH_DMA_MINALIGN, RX_BD_TOTAL_SIZE);
+	if (!priv->rx_bd[0])
+		return -ENOMEM;
 	priv->rx_bd[1] = (struct mcdma_bd *)((ulong)priv->rx_bd[0] +
 					     sizeof(struct mcdma_bd));
 
 	priv->txminframe = memalign(ARCH_DMA_MINALIGN, MIN_PKT_SIZE);
+	if (!priv->txminframe)
+		return -ENOMEM;
 
 	return 0;
 }
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.