Skip to content

Commit

Permalink
net: atlantic: fix potential memory leak in aq_ndev_close()
Browse files Browse the repository at this point in the history
[ Upstream commit 65e5d27 ]

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>
  • Loading branch information
Jianglei Nie authored and gregkh committed Oct 12, 2022
1 parent cfaf7f0 commit 5b4e1c1
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions drivers/net/ethernet/aquantia/atlantic/aq_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,8 @@ static int aq_ndev_close(struct net_device *ndev)
int err = 0;

err = aq_nic_stop(aq_nic);
if (err < 0)
goto err_exit;
aq_nic_deinit(aq_nic, true);

err_exit:
return err;
}

Expand Down

0 comments on commit 5b4e1c1

Please sign in to comment.