[PATCH] wifi: mt76: add DMA mapping error check in mt76_alloc_txwi()

Dmitry Antipov dmantipov at yandex.ru
Fri Sep 1 01:19:04 PDT 2023


Add 'dma_mapping_error()' check in 'mt76_alloc_txwi()'.

Signed-off-by: Dmitry Antipov <dmantipov at yandex.ru>
---
 drivers/net/wireless/mediatek/mt76/dma.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index 05d9ab3ce819..5af666f03398 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -53,6 +53,11 @@ mt76_alloc_txwi(struct mt76_dev *dev)
 
 	addr = dma_map_single(dev->dma_dev, txwi, dev->drv->txwi_size,
 			      DMA_TO_DEVICE);
+	if (unlikely(dma_mapping_error(dev->dma_dev, addr))) {
+		kfree(txwi);
+		return NULL;
+	}
+
 	t = (struct mt76_txwi_cache *)(txwi + dev->drv->txwi_size);
 	t->dma_addr = addr;
 
-- 
2.41.0




More information about the Linux-mediatek mailing list