Skip to contentSkip to conversation

6lowpan: release device on error path

PATCH Applied Dan Carpenter 3 participants 3 messages Nov 7, 2013 – Nov 8, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 6lowpan: release device on error path

We recently added a new error path and it needs a dev_put().

Fixes 7adac1ec8198 ('6lowpan: Only make 6lowpan links to IEEE802154 devices')

---
Compile tested only. Please review carefully.

net/ieee802154/6lowpan.c +3 -1
index 9497c6f..426b5df 100644
@@ -1358,8 +1358,10 @@ static int lowpan_newlink(struct net *src_net, struct net_device *dev,
 	real_dev = dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK]));
 	if (!real_dev)
 		return -ENODEV;
-	if (real_dev->type != ARPHRD_IEEE802154)
+	if (real_dev->type != ARPHRD_IEEE802154) {
+		dev_put(real_dev);
 		return -EINVAL;
+	}
 
 	lowpan_dev_info(dev)->real_dev = real_dev;
 	lowpan_dev_info(dev)->fragment_tag = 0;
maintainer
#1 lore raw
Quoted 12 lines · Dan Carpenter

We recently added a new error path and it needs a dev_put().

Fixes 7adac1ec8198 ('6lowpan: Only make 6lowpan links to IEEE802154 devices')

---
Compile tested only. Please review carefully.

net/ieee802154/6lowpan.c +0 -0
index 9497c6f..426b5df 100644

net/ieee802154/6lowpan.c static int lowpan_newlink(struct net *src_net, struct net_device *dev, · line 1364

Quoted 8 lines
net/ieee802154/6lowpan.c +3 -1
@@ -1358,8 +1358,10 @@ static int lowpan_newlink(struct net *src_net, struct net_device *dev,
 	real_dev = dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK]));
 	if (!real_dev)
 		return -ENODEV;
-	if (real_dev->type != ARPHRD_IEEE802154)
+	if (real_dev->type != ARPHRD_IEEE802154) {
+		dev_put(real_dev);
 		return -EINVAL;
+	}

looks correct for me.