gtp: put back reference to netns when not required anymore
authorPablo Neira <pablo@netfilter.org>
Thu, 12 May 2016 15:16:31 +0000 (17:16 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 12 May 2016 16:27:15 +0000 (12:27 -0400)
This patch fixes a netns leak.

Fixes: 93edb8c7f94f ("gtp: reload GTPv1 header after pskb_may_pull()")
Reported-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/gtp.c

index f7caf1e35d83d8be14a8e6d1da72fae358f094aa..4e976a0d5a764403dc8fc8758a5aec3a7d0328ab 100644 (file)
@@ -1028,8 +1028,11 @@ static int gtp_genl_new_pdp(struct sk_buff *skb, struct genl_info *info)
 
        /* Check if there's an existing gtpX device to configure */
        dev = gtp_find_dev(net, nla_get_u32(info->attrs[GTPA_LINK]));
-       if (dev == NULL)
+       if (dev == NULL) {
+               put_net(net);
                return -ENODEV;
+       }
+       put_net(net);
 
        return ipv4_pdp_add(dev, info);
 }
@@ -1051,8 +1054,11 @@ static int gtp_genl_del_pdp(struct sk_buff *skb, struct genl_info *info)
 
        /* Check if there's an existing gtpX device to configure */
        dev = gtp_find_dev(net, nla_get_u32(info->attrs[GTPA_LINK]));
-       if (dev == NULL)
+       if (dev == NULL) {
+               put_net(net);
                return -ENODEV;
+       }
+       put_net(net);
 
        gtp = netdev_priv(dev);
 
@@ -1163,8 +1169,11 @@ static int gtp_genl_get_pdp(struct sk_buff *skb, struct genl_info *info)
 
        /* Check if there's an existing gtpX device to configure */
        dev = gtp_find_dev(net, nla_get_u32(info->attrs[GTPA_LINK]));
-       if (dev == NULL)
+       if (dev == NULL) {
+               put_net(net);
                return -ENODEV;
+       }
+       put_net(net);
 
        gtp = netdev_priv(dev);