Skip to contentSkip to conversation

gtp: put back reference to netns when not required anymore

PATCH Applied Pablo Neira Ayuso 3 participants 3 messages May 12, 2016

Subsystems (3)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 gtp: put back reference to netns when not required anymore

This patch fixes a netns leak.

Fixes 93edb8c7f94f ("gtp: reload GTPv1 header after pskb_may_pull()")
---
 drivers/net/gtp.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/net/gtp.c +12 -3
index f7caf1e..4e976a0 100644
@@ -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);
 
Signature · 1 line
2.1.4