]> git.baikalelectronics.ru Git - kernel.git/commit
sctp: fix dst refcnt leak in sctp_v6_get_dst()
authorAlexey Kodanev <alexey.kodanev@oracle.com>
Mon, 5 Feb 2018 12:10:35 +0000 (15:10 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 6 Feb 2018 02:21:13 +0000 (21:21 -0500)
commite025afff07d3e5b3af500503c90fa09e0620278a
treedf4f3d6438373a5ed0a6b8e0db5f48dabdb975cd
parentc7bbabe9ad1a39794ff9ed25c730221ef5105eb7
sctp: fix dst refcnt leak in sctp_v6_get_dst()

When going through the bind address list in sctp_v6_get_dst() and
the previously found address is better ('matchlen > bmatchlen'),
the code continues to the next iteration without releasing currently
held destination.

Fix it by releasing 'bdst' before continue to the next iteration, and
instead of introducing one more '!IS_ERR(bdst)' check for dst_release(),
move the already existed one right after ip6_dst_lookup_flow(), i.e. we
shouldn't proceed further if we get an error for the route lookup.

Fixes: 66faea169b90 ("sctp: fix src address selection if using secondary addresses for ipv6")
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/ipv6.c