]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: xilinx: axienet: fix potential memory leak in axienet_start_xmit()
authorWang Hai <wanghai38@huawei.com>
Mon, 14 Oct 2024 14:37:04 +0000 (22:37 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Nov 2024 00:52:34 +0000 (01:52 +0100)
[ Upstream commit 99714e37e8333bbc22496fe80f241d5b35380e83 ]

The axienet_start_xmit() returns NETDEV_TX_OK without freeing skb
in case of dma_map_single() fails, add dev_kfree_skb_any() to fix it.

Fixes: 71791dc8bdea ("net: axienet: Check for DMA mapping errors")
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Link: https://patch.msgid.link/20241014143704.31938-1-wanghai38@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/xilinx/xilinx_axienet_main.c

index f9921e372a2f4e8e107cca69c0fd19dc02b72c08..56a970357f450dde0e401c57561d1c8544c24b2e 100644 (file)
@@ -868,6 +868,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
                if (net_ratelimit())
                        netdev_err(ndev, "TX DMA mapping error\n");
                ndev->stats.tx_dropped++;
+               dev_kfree_skb_any(skb);
                return NETDEV_TX_OK;
        }
        desc_set_phys_addr(lp, phys, cur_p);
@@ -888,6 +889,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
                        ndev->stats.tx_dropped++;
                        axienet_free_tx_chain(lp, orig_tail_ptr, ii + 1,
                                              true, NULL, 0);
+                       dev_kfree_skb_any(skb);
                        return NETDEV_TX_OK;
                }
                desc_set_phys_addr(lp, phys, cur_p);