@@ -1386,19 +1386,18 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
daddr = &sk->sk_v6_daddr;
}
- if (daddr) {
- if (ipv6_addr_v4mapped(daddr)) {
- struct sockaddr_in sin;
- sin.sin_family = AF_INET;
- sin.sin_port = sin6 ? sin6->sin6_port : inet->inet_dport;
- sin.sin_addr.s_addr = daddr->s6_addr32[3];
- msg->msg_name = &sin;
- msg->msg_namelen = sizeof(sin);
+ if (ipv6_addr_v4mapped(daddr)) {
+ struct sockaddr_in sin;
+
+ sin.sin_family = AF_INET;
+ sin.sin_port = sin6 ? sin6->sin6_port : inet->inet_dport;
+ sin.sin_addr.s_addr = daddr->s6_addr32[3];
+ msg->msg_name = &sin;
+ msg->msg_namelen = sizeof(sin);
do_udp_sendmsg:
- if (ipv6_only_sock(sk))
- return -ENETUNREACH;
- return udp_sendmsg(sk, msg, len);
- }
+ if (ipv6_only_sock(sk))
+ return -ENETUNREACH;
+ return udp_sendmsg(sk, msg, len);
}
ulen += sizeof(struct udphdr);
All paths taking udpv6_sendmsg() to the ipv6_addr_v4mapped() check set a non zero daddr, we can safely kill the NULL check just before it. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> --- net/ipv6/udp.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)