net: atlantic: fix potential memory leak in aq_ndev_close()
authorJianglei Nie <niejianglei2021@163.com>
Wed, 14 Sep 2022 01:42:38 +0000 (09:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 12 Oct 2022 07:53:27 +0000 (09:53 +0200)
commite6590139ffa3bc18c7f87754d0b79a93f1ae43c6
treef8ba6a3de140daf75695958f27e40edd7e31c33b
parent005e368a61bc0f3e500f81aad86d04dd2f63ad1d
net: atlantic: fix potential memory leak in aq_ndev_close()

[ Upstream commit 65e5d27df61283e5390f04b09dc79cd832f95607 ]

If aq_nic_stop() fails, aq_ndev_close() returns err without calling
aq_nic_deinit() to release the relevant memory and resource, which
will lead to a memory leak.

We can fix it by deleting the if condition judgment and goto statement to
call aq_nic_deinit() directly after aq_nic_stop() to fix the memory leak.

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/aquantia/atlantic/aq_main.c