Skip to content

Commit

Permalink
chtls: Fix potential resource leak
Browse files Browse the repository at this point in the history
The dst entry should be released if no neighbour is found. Goto label
free_dst to fix the issue. Besides, the check of ndev against NULL is
redundant.

Signed-off-by: Pan Bian <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
SinkFinder authored and kuba-moo committed Jan 23, 2021
1 parent cf3c466 commit b601196
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1158,11 +1158,9 @@ static struct sock *chtls_recv_sock(struct sock *lsk,
#endif
}
if (!n || !n->dev)
goto free_sk;
goto free_dst;

ndev = n->dev;
if (!ndev)
goto free_dst;
if (is_vlan_dev(ndev))
ndev = vlan_dev_real_dev(ndev);

Expand Down Expand Up @@ -1250,7 +1248,8 @@ static struct sock *chtls_recv_sock(struct sock *lsk,
free_csk:
chtls_sock_release(&csk->kref);
free_dst:
neigh_release(n);
if (n)
neigh_release(n);
dst_release(dst);
free_sk:
inet_csk_prepare_forced_close(newsk);
Expand Down

0 comments on commit b601196

Please sign in to comment.