]> git.baikalelectronics.ru Git - kernel.git/commit
bnx2x: fix potential memory leak in bnx2x_tpa_stop()
authorJianglei Nie <niejianglei2021@163.com>
Fri, 30 Sep 2022 06:28:43 +0000 (14:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 11:22:26 +0000 (13:22 +0200)
commite1bfb37636c0aa4358db5d831808f88d4d141b74
tree246dffc8557a5232aa5c4cce6975484bef956fd3
parent5922e79366527a875199bd6b233103ccf1c788dc
bnx2x: fix potential memory leak in bnx2x_tpa_stop()

[ Upstream commit b29b51f0091e1af1bcb41d3a2e0464031b821906 ]

bnx2x_tpa_stop() allocates a memory chunk from new_data with
bnx2x_frag_alloc(). The new_data should be freed when gets some error.
But when "pad + len > fp->rx_buf_size" is true, bnx2x_tpa_stop() returns
without releasing the new_data, which will lead to a memory leak.

We should free the new_data with bnx2x_frag_free() when "pad + len >
fp->rx_buf_size" is true.

Fixes: 2dbef7a5a742505cd976e5993c1ae5baff0f74c1 ("bnx2x: fix possible panic under memory stress")
Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c