Skip to content

Commit 29211e7

Browse files
rtg-canonicaldavem330
authored andcommitted
mptcp: Avoid NULL dereference in mptcp_getsockopt_subflow_addrs()
Coverity complains of a possible NULL dereference in mptcp_getsockopt_subflow_addrs(): 861 } else if (sk->sk_family == AF_INET6) { 3. returned_null: inet6_sk returns NULL. [show details] 4. var_assigned: Assigning: np = NULL return value from inet6_sk. 862 const struct ipv6_pinfo *np = inet6_sk(sk); Fix this by checking for NULL. Closes: multipath-tcp/mptcp_net-next#231 Fixes: c11c590 ("mptcp: add MPTCP_SUBFLOW_ADDRS getsockopt support") Cc: Florian Westphal <[email protected]> Signed-off-by: Tim Gardner <[email protected]> [mjm: Added WARN_ON_ONCE() to the unexpected case] Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 295711f commit 29211e7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/mptcp/sockopt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,9 @@ static void mptcp_get_sub_addrs(const struct sock *sk, struct mptcp_subflow_addr
861861
} else if (sk->sk_family == AF_INET6) {
862862
const struct ipv6_pinfo *np = inet6_sk(sk);
863863

864+
if (WARN_ON_ONCE(!np))
865+
return;
866+
864867
a->sin6_local.sin6_family = AF_INET6;
865868
a->sin6_local.sin6_port = inet->inet_sport;
866869

0 commit comments

Comments
 (0)