diff options
author | Jianglei Nie <niejianglei2021@163.com> | 2022-09-30 14:28:43 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-10-26 13:19:26 +0200 |
commit | 70421f9708d4cf14c2bd15de58862a3d22e00bbe (patch) | |
tree | 434b7d7d52a3acaf57c45f34205ce1ecb3f625a1 | |
parent | e3cb25d3ad08f5dbd53ce2b31720cad529944322 (diff) | |
download | linux-stable-70421f9708d4cf14c2bd15de58862a3d22e00bbe.tar.gz linux-stable-70421f9708d4cf14c2bd15de58862a3d22e00bbe.tar.bz2 linux-stable-70421f9708d4cf14c2bd15de58862a3d22e00bbe.zip |
bnx2x: fix potential memory leak in bnx2x_tpa_stop()
[ Upstream commit b43f9acbb8942b05252be83ac25a81cec70cc192 ]
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: 07b0f00964def8af9321cfd6c4a7e84f6362f728 ("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>
-rw-r--r-- | drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 2610acf9ac36..53b1b05f905e 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -788,6 +788,7 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, BNX2X_ERR("skb_put is about to fail... pad %d len %d rx_buf_size %d\n", pad, len, fp->rx_buf_size); bnx2x_panic(); + bnx2x_frag_free(fp, new_data); return; } #endif |