]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
cxgb4: fix memory leak in cxgb4_init_ethtool_filters() error path
authorAbdun Nihaal <abdun.nihaal@gmail.com>
Mon, 14 Apr 2025 17:06:46 +0000 (22:36 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:44:10 +0000 (07:44 +0200)
commit118d05b530343cd9322607b9719405ba254a4183
treeacd064a95cb4269672b7f8e3fad0d8ed8e51422c
parenta27526e6b48eee9e2d82efff502c4f272f1a91d4
cxgb4: fix memory leak in cxgb4_init_ethtool_filters() error path

[ Upstream commit 00ffb3724ce743578163f5ade2884374554ca021 ]

In the for loop used to allocate the loc_array and bmap for each port, a
memory leak is possible when the allocation for loc_array succeeds,
but the allocation for bmap fails. This is because when the control flow
goes to the label free_eth_finfo, only the allocations starting from
(i-1)th iteration are freed.

Fix that by freeing the loc_array in the bmap allocation error path.

Fixes: d915c299f1da ("cxgb4: add skeleton for ethtool n-tuple filters")
Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://patch.msgid.link/20250414170649.89156-1-abdun.nihaal@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c