net: erspan: remove md NULL check
authorWilliam Tu <u9012063@gmail.com>
Thu, 21 Dec 2017 23:51:22 +0000 (15:51 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 26 Dec 2017 22:30:11 +0000 (17:30 -0500)
The 'md' is allocated from 'tun_dst = ip_tun_rx_dst' and
since we've checked 'tun_dst', 'md' will never be NULL.
The patch removes it at both ipv4 and ipv6 erspan.

Fixes: afb4c97d90e6 ("ip6_gre: fix potential memory leak in ip6erspan_rcv")
Fixes: 50670b6ee9bc ("ip_gre: fix potential memory leak in erspan_rcv")
Cc: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ip_gre.c
net/ipv6/ip6_gre.c

index 78365094f56cd8f8ced935e9ec319520b5279f7d..b61f2285816d230baf54a604641837aa4f0018f2 100644 (file)
@@ -313,11 +313,6 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
                                return PACKET_REJECT;
 
                        md = ip_tunnel_info_opts(&tun_dst->u.tun_info);
-                       if (!md) {
-                               dst_release((struct dst_entry *)tun_dst);
-                               return PACKET_REJECT;
-                       }
-
                        memcpy(md, pkt_md, sizeof(*md));
                        md->version = ver;
 
index 97f148f154298259dbb46fef65b8812f9c5a26db..b345b7e484c5ec4316f1994e4cd96ddf83cb5e06 100644 (file)
@@ -550,10 +550,6 @@ static int ip6erspan_rcv(struct sk_buff *skb, int gre_hdr_len,
 
                        info = &tun_dst->u.tun_info;
                        md = ip_tunnel_info_opts(info);
-                       if (!md) {
-                               dst_release((struct dst_entry *)tun_dst);
-                               return PACKET_REJECT;
-                       }
 
                        memcpy(md, pkt_md, sizeof(*md));
                        md->version = ver;