Commit b6011966 authored by Pan Bian's avatar Pan Bian Committed by Jakub Kicinski

chtls: Fix potential resource leak

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: default avatarPan Bian <bianpan2016@163.com>
Link: https://lore.kernel.org/r/20210121145738.51091-1-bianpan2016@163.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent cf3c4663
...@@ -1158,11 +1158,9 @@ static struct sock *chtls_recv_sock(struct sock *lsk, ...@@ -1158,11 +1158,9 @@ static struct sock *chtls_recv_sock(struct sock *lsk,
#endif #endif
} }
if (!n || !n->dev) if (!n || !n->dev)
goto free_sk; goto free_dst;
ndev = n->dev; ndev = n->dev;
if (!ndev)
goto free_dst;
if (is_vlan_dev(ndev)) if (is_vlan_dev(ndev))
ndev = vlan_dev_real_dev(ndev); ndev = vlan_dev_real_dev(ndev);
...@@ -1250,7 +1248,8 @@ static struct sock *chtls_recv_sock(struct sock *lsk, ...@@ -1250,7 +1248,8 @@ static struct sock *chtls_recv_sock(struct sock *lsk,
free_csk: free_csk:
chtls_sock_release(&csk->kref); chtls_sock_release(&csk->kref);
free_dst: free_dst:
neigh_release(n); if (n)
neigh_release(n);
dst_release(dst); dst_release(dst);
free_sk: free_sk:
inet_csk_prepare_forced_close(newsk); inet_csk_prepare_forced_close(newsk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment