* [PATCH] net: nixge: fix skb leak and missing bail on DMA mapping error
@ 2026-04-26 21:33 kernelcoredev
2026-04-27 2:42 ` Andrew Lunn
0 siblings, 1 reply; 7+ messages in thread
From: kernelcoredev @ 2026-04-26 21:33 UTC (permalink / raw)
To: netdev; +Cc: andrew+netdev, davem, edumazet, kuba, pabeni, kernelcoredev
When dma_mapping_error() fires during RX buffer refill in nixge_recv(),
the skb allocated by netdev_alloc_skb_ip_align() is never freed, and
execution continues writing a corrupt physical address into the hardware
descriptor ring.
Fix by freeing the skb with dev_kfree_skb() and returning early.
Fixes: 492caffa8a1a ("net: ethernet: nixge: Add support for National Instruments XGE netdev")
Signed-off-by: kernelcoredev <sonionwhat@gmail.com>
---
drivers/net/ethernet/ni/nixge.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
index 230d5ff99..b64e2f355 100644
--- a/drivers/net/ethernet/ni/nixge.c
+++ b/drivers/net/ethernet/ni/nixge.c
@@ -645,8 +645,9 @@ static int nixge_recv(struct net_device *ndev, int budget)
NIXGE_MAX_JUMBO_FRAME_SIZE,
DMA_FROM_DEVICE);
if (dma_mapping_error(ndev->dev.parent, cur_phys)) {
- /* FIXME: bail out and clean up */
- netdev_err(ndev, "Failed to map ...\n");
+ netdev_err(ndev, "Failed to map RX buffer\n");
+ dev_kfree_skb(new_skb);
+ return packets;
}
nixge_hw_dma_bd_set_phys(cur_p, cur_phys);
cur_p->cntrl = NIXGE_MAX_JUMBO_FRAME_SIZE;
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] net: nixge: fix skb leak and missing bail on DMA mapping error
2026-04-26 21:33 kernelcoredev
@ 2026-04-27 2:42 ` Andrew Lunn
0 siblings, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2026-04-27 2:42 UTC (permalink / raw)
To: kernelcoredev; +Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni
On Sun, Apr 26, 2026 at 05:33:16PM -0400, kernelcoredev wrote:
> When dma_mapping_error() fires during RX buffer refill in nixge_recv(),
> the skb allocated by netdev_alloc_skb_ip_align() is never freed, and
> execution continues writing a corrupt physical address into the hardware
> descriptor ring.
>
> Fix by freeing the skb with dev_kfree_skb() and returning early.
>
> Fixes: 492caffa8a1a ("net: ethernet: nixge: Add support for National Instruments XGE netdev")
>
> Signed-off-by: kernelcoredev <sonionwhat@gmail.com>
Please read
https://docs.kernel.org/process/submitting-patches.html
In particular:
https://docs.kernel.org/process/submitting-patches.html#developer-s-certificate-of-origin-1-1
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] net: nixge: fix skb leak and missing bail on DMA mapping error
@ 2026-04-27 6:00 kernelcoredev
2026-04-27 13:02 ` Andrew Lunn
0 siblings, 1 reply; 7+ messages in thread
From: kernelcoredev @ 2026-04-27 6:00 UTC (permalink / raw)
To: netdev; +Cc: andrew, andrew+netdev, davem, edumazet, kuba, pabeni,
kernelcoredev
When dma_mapping_error() fires during RX buffer refill in nixge_recv(),
the skb allocated by netdev_alloc_skb_ip_align() is never freed, and
execution continues writing a corrupt physical address into the hardware
descriptor ring.
Fix by freeing the skb with dev_kfree_skb() and returning early.
Fixes: 492caffa8a1a ("net: ethernet: nixge: Add support for National Instruments XGE netdev")
Signed-off-by: Bentley Blacketer <sonionwhat@gmail.com>
---
drivers/net/ethernet/ni/nixge.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
index 230d5ff99..b64e2f355 100644
--- a/drivers/net/ethernet/ni/nixge.c
+++ b/drivers/net/ethernet/ni/nixge.c
@@ -645,8 +645,9 @@ static int nixge_recv(struct net_device *ndev, int budget)
NIXGE_MAX_JUMBO_FRAME_SIZE,
DMA_FROM_DEVICE);
if (dma_mapping_error(ndev->dev.parent, cur_phys)) {
- /* FIXME: bail out and clean up */
- netdev_err(ndev, "Failed to map ...\n");
+ netdev_err(ndev, "Failed to map RX buffer\n");
+ dev_kfree_skb(new_skb);
+ return packets;
}
nixge_hw_dma_bd_set_phys(cur_p, cur_phys);
cur_p->cntrl = NIXGE_MAX_JUMBO_FRAME_SIZE;
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] net: nixge: fix skb leak and missing bail on DMA mapping error
2026-04-27 6:00 kernelcoredev
@ 2026-04-27 13:02 ` Andrew Lunn
0 siblings, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2026-04-27 13:02 UTC (permalink / raw)
To: kernelcoredev; +Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni
On Mon, Apr 27, 2026 at 02:00:46AM -0400, kernelcoredev wrote:
> When dma_mapping_error() fires during RX buffer refill in nixge_recv(),
> the skb allocated by netdev_alloc_skb_ip_align() is never freed, and
> execution continues writing a corrupt physical address into the hardware
> descriptor ring.
>
> Fix by freeing the skb with dev_kfree_skb() and returning early.
>
> Fixes: 492caffa8a1a ("net: ethernet: nixge: Add support for National Instruments XGE netdev")
>
> Signed-off-by: Bentley Blacketer <sonionwhat@gmail.com>
> ---
> drivers/net/ethernet/ni/nixge.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
> index 230d5ff99..b64e2f355 100644
> --- a/drivers/net/ethernet/ni/nixge.c
> +++ b/drivers/net/ethernet/ni/nixge.c
> @@ -645,8 +645,9 @@ static int nixge_recv(struct net_device *ndev, int budget)
> NIXGE_MAX_JUMBO_FRAME_SIZE,
> DMA_FROM_DEVICE);
> if (dma_mapping_error(ndev->dev.parent, cur_phys)) {
> - /* FIXME: bail out and clean up */
> - netdev_err(ndev, "Failed to map ...\n");
> + netdev_err(ndev, "Failed to map RX buffer\n");
> + dev_kfree_skb(new_skb);
> + return packets;
Please add to the commit message an explanation of how you tested
this. Did you hack dma_mapping_error() so that 1 in 1000 is returned
an error?
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] net: nixge: fix skb leak and missing bail on DMA mapping error
@ 2026-04-27 16:20 kernelcoredev
0 siblings, 0 replies; 7+ messages in thread
From: kernelcoredev @ 2026-04-27 16:20 UTC (permalink / raw)
To: netdev; +Cc: andrew, andrew+netdev, davem, edumazet, kuba, pabeni,
kernelcoredev
When dma_mapping_error() fires during RX buffer refill in nixge_recv(),
the skb allocated by netdev_alloc_skb_ip_align() is never freed, and
execution continues writing a corrupt physical address into the hardware
descriptor ring.
Fix by freeing the skb with dev_kfree_skb() and returning early.
This was tested via code inspection, as I do not have access to the
hardware. If dma_mapping_error() occurs, the current code continues
execution, which can leak the skb and program an invalid DMA address
into the descriptor ring. This patch ensures proper cleanup and early
return on error.
Fixes: 492caffa8a1a ("net: ethernet: nixge: Add support for National Instruments XGE netdev")
Signed-off-by: Bentley Blacketer <sonionwhat@gmail.com>
---
drivers/net/ethernet/ni/nixge.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
index 230d5ff99..b64e2f355 100644
--- a/drivers/net/ethernet/ni/nixge.c
+++ b/drivers/net/ethernet/ni/nixge.c
@@ -645,8 +645,9 @@ static int nixge_recv(struct net_device *ndev, int budget)
NIXGE_MAX_JUMBO_FRAME_SIZE,
DMA_FROM_DEVICE);
if (dma_mapping_error(ndev->dev.parent, cur_phys)) {
- /* FIXME: bail out and clean up */
- netdev_err(ndev, "Failed to map ...\n");
+ netdev_err(ndev, "Failed to map RX buffer\n");
+ dev_kfree_skb(new_skb);
+ return packets;
}
nixge_hw_dma_bd_set_phys(cur_p, cur_phys);
cur_p->cntrl = NIXGE_MAX_JUMBO_FRAME_SIZE;
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] net: nixge: fix skb leak and missing bail on DMA mapping error
@ 2026-04-27 17:46 kernelcoredev
2026-04-27 18:14 ` Andrew Lunn
0 siblings, 1 reply; 7+ messages in thread
From: kernelcoredev @ 2026-04-27 17:46 UTC (permalink / raw)
To: netdev; +Cc: andrew, andrew+netdev, davem, edumazet, kuba, pabeni,
kernelcoredev
When dma_mapping_error() fires during RX buffer refill in nixge_recv(),
the skb allocated by netdev_alloc_skb_ip_align() is never freed, and
execution continues writing a corrupt physical address into the hardware
descriptor ring.
Fix by freeing the skb with dev_kfree_skb() and returning early.
This was tested via code inspection, as I do not have access to the
hardware. If dma_mapping_error() occurs, the current code continues
execution, which can leak the skb and program an invalid DMA address
into the descriptor ring. This patch ensures proper cleanup and early
return on error.
Fixes: 492caffa8a1a ("net: ethernet: nixge: Add support for National Instruments XGE netdev")
Signed-off-by: Bentley Blacketer <sonionwhat@gmail.com>
---
drivers/net/ethernet/ni/nixge.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
index 230d5ff99..b64e2f355 100644
--- a/drivers/net/ethernet/ni/nixge.c
+++ b/drivers/net/ethernet/ni/nixge.c
@@ -645,8 +645,9 @@ static int nixge_recv(struct net_device *ndev, int budget)
NIXGE_MAX_JUMBO_FRAME_SIZE,
DMA_FROM_DEVICE);
if (dma_mapping_error(ndev->dev.parent, cur_phys)) {
- /* FIXME: bail out and clean up */
- netdev_err(ndev, "Failed to map ...\n");
+ netdev_err(ndev, "Failed to map RX buffer\n");
+ dev_kfree_skb(new_skb);
+ return packets;
}
nixge_hw_dma_bd_set_phys(cur_p, cur_phys);
cur_p->cntrl = NIXGE_MAX_JUMBO_FRAME_SIZE;
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] net: nixge: fix skb leak and missing bail on DMA mapping error
2026-04-27 17:46 [PATCH] net: nixge: fix skb leak and missing bail on DMA mapping error kernelcoredev
@ 2026-04-27 18:14 ` Andrew Lunn
0 siblings, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2026-04-27 18:14 UTC (permalink / raw)
To: kernelcoredev; +Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni
On Mon, Apr 27, 2026 at 01:46:07PM -0400, kernelcoredev wrote:
> When dma_mapping_error() fires during RX buffer refill in nixge_recv(),
> the skb allocated by netdev_alloc_skb_ip_align() is never freed, and
> execution continues writing a corrupt physical address into the hardware
> descriptor ring.
>
> Fix by freeing the skb with dev_kfree_skb() and returning early.
>
> This was tested via code inspection, as I do not have access to the
> hardware. If dma_mapping_error() occurs, the current code continues
> execution, which can leak the skb and program an invalid DMA address
> into the descriptor ring. This patch ensures proper cleanup and early
> return on error.
Please continue your code inspection. What happens to the ring
descriptors if you return early?
If the fix was so simple, why do you think there is a FIXME? This is
the problem of not testing on hardware. Do you know if your change
makes the code better or worse? Please argue why it is better,
including an explanation of what happens to the ring descriptors with
your fix in place.
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-04-27 18:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 17:46 [PATCH] net: nixge: fix skb leak and missing bail on DMA mapping error kernelcoredev
2026-04-27 18:14 ` Andrew Lunn
-- strict thread matches above, loose matches on Subject: below --
2026-04-27 16:20 kernelcoredev
2026-04-27 6:00 kernelcoredev
2026-04-27 13:02 ` Andrew Lunn
2026-04-26 21:33 kernelcoredev
2026-04-27 2:42 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox