[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230205201130.11303-3-jsc@umbraculum.org>
Date: Sun, 5 Feb 2023 21:11:28 +0100
From: Jonas Suhr Christensen <jsc@...raculum.org>
To: netdev@...r.kernel.org
Cc: jsc@...raculum.org, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Michal Simek <michal.simek@...inx.com>,
Harini Katakam <harini.katakam@....com>,
Haoyue Xu <xuhaoyue1@...ilicon.com>,
huangjunxian <huangjunxian6@...ilicon.com>,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
Yang Yingliang <yangyingliang@...wei.com>,
Esben Haabendal <esben@...nix.com>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH net v2 2/2] net: ll_temac: Reset buffer on dma_map_single() errors
To avoid later calls to dma_unmap_single() on address'
that fails to be mapped, free the allocated skb and
set the pointer of the address to NULL. Eg. when a mapping
fails temac_dma_bd_release() will try to call dma_unmap_single()
on that address if the structure is not reset.
Fixes: d07c849cd2b9 ("net: ll_temac: Add more error handling of dma_map_single() calls")
Signed-off-by: Jonas Suhr Christensen <jsc@...raculum.org>
---
drivers/net/ethernet/xilinx/ll_temac_main.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index 74423adbe50d..df43f5bc3bd3 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -376,8 +376,11 @@ static int temac_dma_bd_init(struct net_device *ndev)
skb_dma_addr = dma_map_single(ndev->dev.parent, skb->data,
XTE_MAX_JUMBO_FRAME_SIZE,
DMA_FROM_DEVICE);
- if (dma_mapping_error(ndev->dev.parent, skb_dma_addr))
+ if (dma_mapping_error(ndev->dev.parent, skb_dma_addr)) {
+ dev_kfree_skb(lp->rx_skb[i]);
+ lp->rx_skb[i] = NULL;
goto out;
+ }
lp->rx_bd_v[i].phys = cpu_to_be32(skb_dma_addr);
lp->rx_bd_v[i].len = cpu_to_be32(XTE_MAX_JUMBO_FRAME_SIZE);
lp->rx_bd_v[i].app0 = cpu_to_be32(STS_CTRL_APP0_IRQONEND);
--
2.39.1
Powered by blists - more mailing lists