} rep;
        struct ip_reply_arg arg;
 #ifdef CONFIG_TCP_MD5SIG
-       struct tcp_md5sig_key *key;
+       struct tcp_md5sig_key *key = NULL;
        const __u8 *hash_location = NULL;
        unsigned char newhash[16];
        int genhash;
        net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev);
 #ifdef CONFIG_TCP_MD5SIG
        hash_location = tcp_parse_md5sig_option(th);
-       if (!sk && hash_location) {
+       if (sk) {
+               key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)
+                                       &ip_hdr(skb)->saddr, AF_INET);
+       } else if (hash_location) {
                /*
                 * active side is lost. Try to find listening socket through
                 * source port, and then find md5 key through listening socket.
                genhash = tcp_v4_md5_hash_skb(newhash, key, NULL, skb);
                if (genhash || memcmp(hash_location, newhash, 16) != 0)
                        goto release_sk1;
-       } else {
-               key = sk ? tcp_md5_do_lookup(sk, (union tcp_md5_addr *)
-                                            &ip_hdr(skb)->saddr,
-                                            AF_INET) : NULL;
        }
 
        if (key) {
 
 
 #ifdef CONFIG_TCP_MD5SIG
        hash_location = tcp_parse_md5sig_option(th);
-       if (!sk && hash_location) {
+       if (sk) {
+               key = tcp_v6_md5_do_lookup(sk, &ipv6h->saddr);
+       } else if (hash_location) {
                /*
                 * active side is lost. Try to find listening socket through
                 * source port, and then find md5 key through listening socket.
                genhash = tcp_v6_md5_hash_skb(newhash, key, NULL, skb);
                if (genhash || memcmp(hash_location, newhash, 16) != 0)
                        goto release_sk1;
-       } else {
-               key = sk ? tcp_v6_md5_do_lookup(sk, &ipv6h->saddr) : NULL;
        }
 #endif