net: fec: fix the potential memory leak in fec_enet_init()
authorFugang Duan <fugang.duan@nxp.com>
Wed, 12 May 2021 02:43:59 +0000 (10:43 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Jun 2021 06:59:13 +0000 (08:59 +0200)
commit20255d41ac560397b6a07d8d87dcc5e2efc7672a
tree750bf9fb6a2d9ac1714bb5c7311c9a9550eb4622
parent41f7f37ddefe47e157faeb1cd71e850883bba33c
net: fec: fix the potential memory leak in fec_enet_init()

[ Upstream commit 619fee9eb13b5d29e4267cb394645608088c28a8 ]

If the memory allocated for cbd_base is failed, it should
free the memory allocated for the queues, otherwise it causes
memory leak.

And if the memory allocated for the queues is failed, it can
return error directly.

Fixes: 59d0f7465644 ("net: fec: init multi queue date structure")
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/freescale/fec_main.c