]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: ethernet: ti: am65-cpsw: fix memleak in certain XDP cases
authorRoger Quadros <rogerq@kernel.org>
Mon, 10 Feb 2025 14:52:15 +0000 (16:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Feb 2025 13:01:18 +0000 (14:01 +0100)
commit1bba1d042107167164a0ae3a843fdf650ab005d7
treeb7df24f9e50fbd6b5fbe1557188e0b6f104739b5
parent1dfb37ec8f012a8466b2e624b35d1b411dd10b01
net: ethernet: ti: am65-cpsw: fix memleak in certain XDP cases

[ Upstream commit 5db843258de1e4e6b1ef1cbd1797923c9e3de548 ]

If the XDP program doesn't result in XDP_PASS then we leak the
memory allocated by am65_cpsw_build_skb().

It is pointless to allocate SKB memory before running the XDP
program as we would be wasting CPU cycles for cases other than XDP_PASS.
Move the SKB allocation after evaluating the XDP program result.

This fixes the memleak. A performance boost is seen for XDP_DROP test.

XDP_DROP test:
Before: 460256 rx/s                  0 err/s
After:  784130 rx/s                  0 err/s

Fixes: 8acacc40f733 ("net: ethernet: ti: am65-cpsw: Add minimal XDP support")
Signed-off-by: Roger Quadros <rogerq@kernel.org>
Link: https://patch.msgid.link/20250210-am65-cpsw-xdp-fixes-v1-1-ec6b1f7f1aca@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/ti/am65-cpsw-nuss.c