From: Jonas Suhr Christensen <jsc@umbraculum.org>
To: netdev@vger.kernel.org
Cc: jsc@umbraculum.org, "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Michal Simek <michal.simek@xilinx.com>,
Harini Katakam <harini.katakam@amd.com>,
Haoyue Xu <xuhaoyue1@hisilicon.com>,
huangjunxian <huangjunxian6@hisilicon.com>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Yang Yingliang <yangyingliang@huawei.com>,
Esben Haabendal <esben@geanix.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net v2 2/2] net: ll_temac: Reset buffer on dma_map_single() errors
Date: Sun, 5 Feb 2023 21:11:28 +0100 [thread overview]
Message-ID: <20230205201130.11303-3-jsc@umbraculum.org> (raw)
In-Reply-To: <20230205201130.11303-1-jsc@umbraculum.org>
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@umbraculum.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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-02-05 20:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-05 20:11 [PATCH net v2 0/2] Fix dma leaking Jonas Suhr Christensen
2023-02-05 20:11 ` [PATCH net v2 1/2] net: ll_temac: Fix DMA resources leak Jonas Suhr Christensen
2023-02-06 10:19 ` Katakam, Harini
2023-02-07 7:59 ` esben
2023-02-07 11:27 ` Paolo Abeni
2023-02-07 11:36 ` Paolo Abeni
2023-02-07 18:42 ` Jakub Kicinski
2023-03-13 18:37 ` Jonas Suhr Christensen
2023-03-13 18:48 ` Jakub Kicinski
2023-03-14 5:15 ` Katakam, Harini
2023-07-08 13:15 ` Christophe JAILLET
2023-07-10 5:51 ` Katakam, Harini
2023-09-20 11:56 ` Katakam, Harini
2023-02-05 20:11 ` Jonas Suhr Christensen [this message]
2023-02-06 9:59 ` [PATCH net v2 2/2] net: ll_temac: Reset buffer on dma_map_single() errors Katakam, Harini
2023-02-07 7:59 ` esben
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230205201130.11303-3-jsc@umbraculum.org \
--to=jsc@umbraculum.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=esben@geanix.com \
--cc=harini.katakam@amd.com \
--cc=huangjunxian6@hisilicon.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@xilinx.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=xuhaoyue1@hisilicon.com \
--cc=yangyingliang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).